Jquery - 兄弟姐妹('label')。show()在IE7中不能用于复选框点击,但适用于Dropdown更改

时间:2013-06-04 15:10:17

标签: jquery html internet-explorer-7

我有一个代码片段,点击checckbox我隐藏并显示字段及其标签。

在IE7中

虽然使用兄弟姐妹的hide()工作正常, 但再次单击复选框,兄弟姐妹(标签).show()不起作用

HTML CODE

  

更新

    <div class="rightcolumn" id="otherlabeldiv">
                    <p class="clearboth">
                      <label for="othermakemodel"> Other Make & Model</label>
                      <input type="checkbox" name="othermakemodel" id="othermakemodel" value="1" class="chk"  />
                    </p>
                  </div>
<div class="rightcolumn" id="otherdiv" style="display:none;">
    <p class="clearboth">
                      <label for="cemake">* Make</label>
                      <select name="cemake" id="cemake" class="required">
                        <option value="Please Select">--Please Select--</option>
                        <option value="Other">Other</option>
                      </select>
                    </p>
                    <p class="clearboth">
                      <label for="cemodel">* Model</label>
                      <select name="cemodel" id="cemodel" class="required">
                        <option value="">--Please Select--</option>
                        <!-- <option value="Other">Other</option>-->
                      </select>
                    </p>
</div>

使用JQUERY

 function setUpAjaxCalls(){

        $('#cemake').live('change', function() {
        var val = $('#cemake :selected').text();
        val = val.replace("(",'&#040;');
        val = val.replace(")",'&#041;');
        val = encodeURIComponent(val);

        if (val == 'Other'){
        //alert(val);
                        $('#othermakemodel').hide();
                        $('#othermakemodel').siblings('label').hide();
                        $('#other_hide').val('1');
                        $('#otherdiv').show();
                        $('#cemodel').hide();
                        $('#cemodel').siblings('label').hide();
        }else{
            $('#other_hide').val('');
            $('#othermakemodel').show();
            $('#othermakemodel').siblings('label').show();
            $('#otherdiv').hide();
            $('#cemodel').show();
            $('#cemodel').siblings('label').show();
        }

    });
    }

$(document).ready(function(){
setUpAjaxCalls();
    $("#othermakemodel").click(function() {
            if($('#othermakemodel').is(':checked')){
             $('#cemake').hide();

                $('#cemake').siblings('label').hide();



               $('#cemodel').hide();

               $('#cemodel').siblings('label').hide();
            }else{
            $('#cemake').show();// THIS WORKs
                $('#cemake').siblings('label').show(); // THIS DOESNT WORK
            $('#cemodel').show();// THIS WORKs
                $('#cemodel').siblings('label').show();// THIS DOESNT WORK  
            }
    }); 
});

请帮我解决这个问题。

上面是更新的代码,您可以在其中看到“cemake”到“其他”节点的值的变化/显示具有相同兄弟概念的其他制作/模型文本框,这对于复选框不起作用... < / p>

0 个答案:

没有答案