jquery - Trouble understanding how to use .on properly -
this question has answer here:
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
Post a Comment