I have a button using onclick return confirm ... I wish when the confirm submitted... the second time to click the button it will pop up alert message to inform the user button only can click once time.
SO far , I have already try the one function but not working.
$("#once").one("click", function() {
alert('this only happens once');
});
The following code is my button
<input type="submit" id="once" class="button" style="width:100px;" onclick="return
confirm('Are you sure you want <?php echo $show_venue['venue'];?> be your party venue
?');" value="CHOOSE" name="choose_venue">
You're not disabling the button after the click.
$(this).prop('disabled', true);
Here's a fiddle with the code you are after: http://jsfiddle.net/UT79m/6/
You could add a class to set a 'selected' state after the first click:
$("#once").on("click", function() {
if($(this).hasClass('selected'))
return;
alert('this only happens once');
$(this).addClass('selected');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.