-2

我有这个 JQuery 来显示/隐藏在 IE9 中不起作用的行,它对时间非常敏感,我完全不知道如何修复它。我尝试为 IE8 添加一个元标记,使其工作,但完全搞砸了格式。我不确定它在 IE8 中的本机功能。它确实在 Firefox 和 Chrome 中起作用。

function showNext(opt)  {       
      takeAway();     

      var optMap={
             "Picked Up":"#pickedup",
             "Bus to alternate":"#altad2,#altad1",
             "Walk to alternate":"#altad2,#altad1",
              };
           $(optMap[opt]).css("display","") ;       

}

函数在这里被调用

<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>

显示的行如下

<tr class="~[evenoddrow]" id="pickedup" style="display:none;"> 
<td class="bold">Name of the person that will be picking up your child:</td><td id="Emergclose_Who_Pickup">~([01]Emergclose_Who_Pickup)</td><td class="gwCen"></td>
        <td><input type="text" name="eReg|Emergclose_Who_Pickup" id="eReg|Emergclose_Who_Pickup" value="" size="30" /><span class="gwExample">last,&nbsp; first</span></td>
    </tr>
<tr class="~[evenoddrow]"  id="altad1" style="display:none;"> 
        <td class="bold"><span style="padding: 0 25px">I would like my child to go to the home of:</td></span><td id="Emergclose_Alt_Name">~([01]Emergclose_Alt_Name)</td><td class="gwCen"></td>
        <td><input type="text" name="eReg|Emergclose_Alt_Name" id="eReg|Emergclose_Alt_Name" value="" size="30" /><span class="gwExample">last,&nbsp; first</span></td>
    </tr>   
<tr class="~[evenoddrow]" id="altad2" style="display:none;"> 
        <td class="bold"><span style="padding: 0 25px">Address of Alternate Location:</td></span><td id="Emergclose_Alt_Address">~([01]Emergclose_Alt_Address)</td><td class="gwCen"></td>
        <td><input type="text" name="eReg|Emergclose_Alt_Address" id="eReg|Emergclose_Alt_Address" value="" size="30" /><span class="gwExample">Street Address, City, State, Zip</span></td>
    </tr>   
4

2 回答 2

0

我没有看到那里发生“切换”,那么您是否尝试过设置显示值?

于 2013-05-01T13:20:43.873 回答
0

我使用了这个标记:注意从标记中删除了样式并从标记中删除了代码:

<table>
    <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" class="myselecitem">
                <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>
    <tr class="~[evenoddrow] hiddenstuff choice" id="pickedup">
        <td class="bold">Name of the person that will be picking up your child:</td>
        <td id="Emergclose_Who_Pickup">~([01]Emergclose_Who_Pickup)</td>
        <td class="gwCen"></td>
        <td>
            <input type="text" name="eReg|Emergclose_Who_Pickup" id="eReg|Emergclose_Who_Pickup" value="" size="30" /><span class="gwExample">last,&nbsp; first</span>

        </td>
    </tr>
    <tr class="~[evenoddrow] hiddenstuff choice" id="altad1">
        <td class="bold"><span style="padding: 0 25px">I would like my child to go to the home of:</td></span>

            <td id="Emergclose_Alt_Name">~([01]Emergclose_Alt_Name)</td>
            <td class="gwCen"></td>
            <td>
                <input type="text" name="eReg|Emergclose_Alt_Name" id="eReg|Emergclose_Alt_Name" value="" size="30" /><span class="gwExample">last,&nbsp; first</span>

            </td>
    </tr>
    <tr class="~[evenoddrow] hiddenstuff choice" id="altad2">
        <td class="bold"><span style="padding: 0 25px">Address of Alternate Location:</td></span>

            <td id="Emergclose_Alt_Address">~([01]Emergclose_Alt_Address)</td>
            <td class="gwCen"></td>
            <td>
                <input type="text" name="eReg|Emergclose_Alt_Address" id="eReg|Emergclose_Alt_Address" value="" size="30" /><span class="gwExample">Street Address, City, State, Zip</span>

            </td>
    </tr>
</table>

这个CSS:

.clicked {
    background-color:lime;
}
.hiddenstuff {
    display:none;
}

这段代码:

function showNext(opt) {
    //    takeAway();
    var optMap = {
        "Picked Up": "#pickedup",
            "Bus to alternate": "#altad2,#altad1",
            "Walk to alternate": "#altad2,#altad1"
    };
    $('#Emergclose_Action').text(optMap[opt]);
    $('.choice').removeClass('clicked').addClass('hiddenstuff');
    $(optMap[opt]).addClass('clicked').removeClass('hiddenstuff');
}
$('.myselecitem').change(function () {
    showNext($(this).val());
});

编辑:使用示例:http: //jsbin.com/adexol/2/

于 2013-05-01T15:22:46.097 回答