How can this be converted from .live() to .on()?
$('[id^=generic1_id_]', '[id^=generic2_id_]').live('click', function(){
To convert to .on(), I could create two working examples seen below, but then I have to re-use code in both, whereas with the .live() example, I am able to reference both selectors and the code will be executed on a click event for either selector. Also, I am using .live() because the click handler needs to apply to new elements added/created after the DOM is loaded. I know the .on() examples below will work for existing and new elements, but I must separate them because I can't figure out how to write the code where it will apply to both selectors while using the .on() syntax.
// Generic Example - Click handler for elements with an IDs beginning with "generic1_id_" $(document).on('click', '[id^=generic1_id_]', function(){ }
AND
// Generic Example - Click handler for elements with an IDs beginning with "generic2_id_" $(document).on('click', '[id^=generic2_id_]', function(){ }
I have tried this but it is not correct because the '[id^=generic2_id_]' will be interpreted as data not as a 2nd selector.
// Won't work $(document).on('click', '[id^=generic1_id_]', '[id^=generic2_id_]', function(){
There is surprisingly little I can find in searches to find anything beyond simple examples of converting .live() to .on(). Any ideas?