2017-09-25 99 views
0

我有一個自定義的部分建設者和我有這麼當客戶選擇了選項「全」則執行該腳本當另一個按鈕被選中

$(function() { 
    $("input[name='FirstFlangeSystem']").on("change", function(e) { 
     var newValue = e.target.value; 
     $("input[name='SecondFlangeSystem'][value='" + newValue + "']").prop("checked", true); 
    }); 
    $("select[name='FirstFlangeTypeDrop']").on("change", function(e) { 
     var newValues = $(this).val(); 
     $("select[name='SecondFlangeTypeDrop']").val(newValues); 
    }); 
    document.getElementById("SecondFlangeTypeDrop").disabled = true; 
}); 

問題如何停止腳本是,如果你選擇「Full」選項,然後選擇其他2個選項之一「Half」或「Adapter」,該功能仍在運行。我如何讓它停止?

+1

請您補充一下** HTML **代碼 –

+0

所以聽起來您需要解除事件。或者想想辦法。 – epascarello

+0

我如何取消綁定? –

回答

1

您可以禁用這些字段。如果.Half.Adapter就像複選框,那麼可以這樣做。

var $half = $(".Half"); 
var $adapter = $(".Adapter"); 

$(".Half, .Adapter").on("change", function(e){ 
    if($half.prop("checked") || $adapter.prop("checked")){ 
     $("input[name='FirstFlangeSystem']").prop("disabled", true); 
     $("input[name='FirstFlangeSystem']").prop("disabled", true); 
    }else{ 
     $("input[name='FirstFlangeSystem']").prop("disabled", false); 
     $("input[name='FirstFlangeSystem']").prop("disabled", false); 
    } 
} 
相關問題