KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Can somebody tell what is the difference between jquery .html() function and innerHTML? <script type="text/javascript"> $(document).ready(function(){ $('#test_link').click(function(){ //$('#div_test_out').html("<div width='250px' height='100px' id='div_test'><script language='javascript'>alert('insider');<\/script>asddsa</div>"); document.getElementById('div_test_out').innerHTML="<div width='250px' height='100px' id='div_test'><script language='javascript'>alert('insider');<\/script>asddsa</div>"; }); }); </script> <a href="#" id="test_link" >TEST LINK :-)</a><br/><br/> <div width="100px" height="100px" id="div_test_out"></div> When I use first option, that is jQuery, script inside runs, and alert shows up, but if I use second option that with the innerHTML (which I though is the same and there is no difference between them), script is not working ;-( What could be the cause?
Tags (comma-separated)
Save Edits
Cancel