Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
116 views
in Technique[技术] by (71.8m points)

javascript - Problem with condition and two change event for inputs

I have a problem with a condition and a change event for two inputs. When a change occurs to one of the two inputs, I will check the condition if the two have a value equal to 0, and if it does not, but when the change condition occurs on the two inputs simultaneously and the first is equal to 0, the first event will be executed within the first condition. The second event will be executed within the first condition as well, which must executed within the second condition.

$('.SH-SortByPrice').click(function(){
    $('.SH-PriceMaxSel').val(0).trigger('change');
    $('.SH-PriceMinSel').val(300).trigger('change');
});

$('.SH-PriceMinSel').change(function(){
    Selcted_chick_Pr();
});

$('.SH-PriceMaxSel').change(function(){
     Selcted_chick_Pr();
});

function Selcted_chick_Pr(){

    if(($('.SH-PriceMinSel').val() <= 0) && ($('.SH-PriceMaxSel').val() <= 0)){
          //first execution 
        }else{
          //second  execution 
    };
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input name="PriceMaxSel" class="SH-PriceMaxSel" value="0">
        <input name="PriceMinSel" class="SH-PriceMinSel" value="0">
        <button class="SH-SortByPrice"  >
            <span>execution</span>
        </button>
question from:https://stackoverflow.com/questions/65916523/problem-with-condition-and-two-change-event-for-inputs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...