azraelGG Posted January 10, 2013 Share Posted January 10, 2013 i need check in condition did someone click button or didnt this button is used to display some jQuery and now i want different things to be loaded depending on is it clicked or not - page cant be refreshed that will lead in problem that i need click 2 times on that button <input id="popup" name="popup" type="submit" value="ADD" /> Link to comment https://forums.phpfreaks.com/topic/272972-button-without-form-is-it-clicked/ Share on other sites More sharing options...
Langstra Posted January 10, 2013 Share Posted January 10, 2013 Include the jquery library and do it like this: $(document).ready() { if($("#popup").click(function() { //do something }); } Link to comment https://forums.phpfreaks.com/topic/272972-button-without-form-is-it-clicked/#findComment-1404806 Share on other sites More sharing options...
haku Posted January 11, 2013 Share Posted January 11, 2013 That needs one more line of code: $(document).ready() { if($("#popup").click(function() { //do something return false; }); } Or: $(document).ready() { if($("#popup").click(function(event) { event.preventDefault(); //do something }); } Link to comment https://forums.phpfreaks.com/topic/272972-button-without-form-is-it-clicked/#findComment-1404845 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.