javascript - Specifying jQuery on() to a specific class or id -


i have templating code generates new hyperlinks , buttons have events tied them. possible use on() event binder distinguish different types of buttons based on class attributes, on catching buttons , hyperlinks?

the code working is:

$("#search-results-form").on("click", "button", function(e) {   // on clear }); 
<!-- generated template --> <div id="search-results-form">     <button class="submit">submit</button>     <button class="clear">clear</button> </div> 

you can use selector, here example of class selector

$("#search-results-form").on("click", "button.clear", function(e) {   // on clear }); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -