Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

html - when click on jquery second time not working

Prepaid

$(document).on('click','.prepaid_button',function(){

var sevcount=parseInt($('#services_count').val());

servcount=servcount+1; $('#services_count').val(servcount);

});

question from:https://stackoverflow.com/questions/65856929/when-click-on-jquery-second-time-not-working

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

1 Answer

0 votes
by (71.8m points)

The variable name : sevcount changed to servcount which make the error.

I rename all the variable to sevcount

$(document).on('click','.prepaid_button',function(){
     
     var sevcount=parseInt($('#services_count').val());
      sevcount=sevcount+1; 
      $('#services_count').val(sevcount);

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="prepaid_button" > BUTTON </div>

<input id="services_count" value="0" >

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...