I have a DIV I want to ajax-load. The contains javascript that needs to run. I ran across this SO article that talks about loading the scripts after the main content has loaded. However I cannot get it to work, primarily because I can't find the scripts in my content!
Consider the following:
$('<p />').html('<div>x</div>').find('div').html()
"x"
(for some reason the line below wouldn't work:
$('<p><div>x</div></p>').find('div').html()
null
However, there's something special about scripts:
$('<p />').html('<script>x=1</script>').find('script').html()
null
what am I doing wrong here?
` element to have a `
x
x