0

チェックボックスをクリックすると、フィールドとそのラベルを非表示にして表示するコードスニペットがあります。

IE7で

兄弟を使用した hide() は正常に機能しますが、チェックボックスを再度クリックすると、 siblings(label).show() は機能しません

HTMLコード

アップデート

    <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」の値が「その他」のホードに変更されていることを確認できる更新されたコードです/チェックボックスで機能しない同じ兄弟の概念を持つ他のメーカー/モデルのテキストボックスを表示します...

4

0 に答える 0