ajax - How to combine jQuery-functions with different selectors -


i have unknown number of different id's looks #send_1, #send_2 , on. need call jquery each of id like:

$(document).on("submit", "#send_1", function(e){     var i=1;     if (something true) {             }     }); $(document).on("submit", "#send_2", function(e){     var i=1;     if (something true) ) {             }     }); 

so write hundred times same function changing _x there shall more propper way solve this.

i dont use jquery if there me out appreciate.

thanks in advance.

use attribute starts with(^=) selector

$(document).on("submit", '[id^="send_"]', function(e){     var i=1;     if (something true) ) {             }     }); 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -