Probably a silly question, but still new to JQuery.
I have a div acting as a button to load in content via .load, problem is anything I load in JS will 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 that you need to use .on for already loaded JS to work on dynamically created HTML, however I can't seem to get it right.
Anyone able to help?
Edit: What is wrong with the below?
$('#bb').on('click', '#bb', function(event){
$('#loadb').load('load.htm #cc');
});