有人對SO幫我寫這個劇本的選擇框,它會顯示在下拉負荷運行腳本
function showNext(opt) {
takeAway()
var optMap={
"Picked Up":"#pickedup",
"Bus to alternate":"#altad2,#altad1",
"Walk to alternate":"#altad2,#altad1",
}
$(optMap[opt]).css("display","") ;
}
function takeAway(){
$("#pickedup,#altad2,#altad1").css("display", "none");
}
我需要的東西,會爲這項工作的onload運行基於選擇的選擇隱藏的行也因此,如果事情已被選中的行顯示
下面是將由腳本
<tr class="~[evenoddrow]">
<td class="bold">In the event of early dismissal I would like my child to:</td><td id="Emergclose_Action">~([01]Emergclose_Action)</td><td class="gwCen"></td>
<td><select name="eReg|Emergclose_Action" id="eReg|Emergclose_Action" onChange="showNext(value);">
<option></option><option value="Walk home as normal">Walk home as normal</option><option value="Ride the bus as normal">Ride the bus as normal</option>
<option value="Picked Up">Be picked up immediately after dismissal</option><option value="Bus to alternate">Ride the bus to an alternate address</option><option value="Walk to alternate">Walk to an alternate address</option>
</select>
</td>
</tr>
我嘗試以下影響的選擇並沒有工作..
function showNext(opt) {
takeAway()
var optMap={
"Picked Up":"#pickedup",
"Bus to alternate":"#altad2,#altad1",
"Walk to alternate":"#altad2,#altad1",
}
$(optMap[opt]).css("display","") ;
}
function takeAway(){
$("#pickedup,#altad2,#altad1").css("display", "none");
}
$(function(){
$('#eReg|Emergclose_Action').trigger('onchange');
});
在我看來,有一些缺失的部分。 'showect'方法是否附加到'#eReg | Emergclose_Action'的onchange事件上? – UpHelix 2013-02-21 19:44:39
我也試過用你的例子UpHelix,那也沒有工作 – user2096551 2013-02-21 19:49:12
你的問題很混亂。你想要哪個確切的方法運行onload,並且該方法是否附加到DOM元素? – UpHelix 2013-02-21 19:52:53