jquery - Trouble understanding how to use .on properly -


probably silly question, still new jquery.

i have div acting button load in content via .load, problem load in js not work on it.

html:

<div class="a" id="aa">button #1</div> </br> </br> <div id="loada"></div> </br> </br> <div id="loadb"></div> 

js:

$(document).ready(function(){   $('#aa').click(function(){     $('#loada').load('load.htm #bb'); });   $('#bb').click(function(){     $('#loadn').load('load.htm #cc'); }); 

});

load htm:

<div class="b" id="bb">button #2</div> <div class="c" id="cc">content #1</div> 

i understand need use .on loaded js work on dynamically created html, can't seem right.

anyone able help?

edit: wrong below?

$('#bb').on('click', '#bb', function(event){   $('#loadb').load('load.htm #cc'); }); 

$("#selector").on("click", function(event){ }); 

delegated-events approach attaches event handler 1 elemen

 $("#selector").on("click", "selector", function(event){      }); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -