Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

capture click event of submit button jquery

I am trying to get the click event of a submit button on my form...

<input type="submit" value="Search By Demographics" class="button" id="submitDemo"/>

That is the button that I want to get the event from.

$('#submitDemo').click(
        alert("work darn it!!!!!!!!!!!!!!!!!!!!!!!!!")
        //$("#list").block({ message: '<img src="../../Images/ajax-loader.gif" />' })
    );

This is what I want to do on button click. I want to put a loading image around a div and then unblock later in a different function. Currently the overlay pops up when the page loads instead of onClick. What am I doing

like image 381
SoftwareSavant Avatar asked Sep 10 '12 17:09

SoftwareSavant


1 Answers

try this

$('#submitDemo').live("click",function() {
  // your stuff
});

As @px5x2 pointed that live is deprecate so instead of live use ON

$('#submitDemo').on("click",function() {
  // your stuff
}); 
like image 152
NullPoiиteя Avatar answered Oct 07 '22 16:10

NullPoiиteя