javascript - jQuery; Targeting HTML after .load() -
at /page there next <h1>hello world</h1>
on homepage using;
$(function() { $('#content').load('/page'); });
after loading, next in dom.
<div id="content"> <h1>hello world</h1> </div>
i'd add together class newly loaded h1, try;
$('#content h1').addclass('world');
this fails because h1 inserted after page loaded. how find , target newly added html?
simple, can utilize complete
attribute of .load()
function. read more here http://api.jquery.com/load/
$(function() { $('#content').load('/page', function() { $('#content h1').addclass('world'); }); });
javascript jquery html
No comments:
Post a Comment