i am triyng to acces an elemet using its new atribute.
HTML
<div class="element">Element1</div> The script is
$('.element').one("click", function() { $.getScript('/script.js'); }); $('#activated').click(function() { alert(1); }); Inside the script.js file :
$('.element').attr("id", "activated"); The script.js adds the id #activated to the div, but .click() won't work using the new id.
Can someone please tell me why?
$('#activated').click(...in$(document).ready(...and since you dynamically insert theactivatedid it is not there until you click theelementdiv, which will happen long after$(document).ready(...has executed. So$('#activated')will not be found.