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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…