javascript - modify CSS of elements created via .load() -
first time using jquery. i'm using load content of external element onto page. loads fine, i'm finding normal traversal methods don't work on loaded elements. instance, have is:
<div id="area"></div> <script type="text/javascript"> $("#area").load("externalpage.html #externalelement > *"); $("#area").find("ul").first().css("display","none"); </script>
the second line of script appears nothing. have order in operations completed?
i'm loading custom html module on blackboard lms, can behave strangely if scripting gets complicated, 1 of times. thank helping me figure out!
the call load()
asynchronous. means find()
being run before request completes , elements created in dom.
to workaround can put logic in callback parameter of load()
. means not called until request completes , dom in state expect. try this:
$("#area").load("externalpage.html #externalelement > *", function() { $("#area").find("ul").first().css("display","none"); });
Comments
Post a Comment