Created
March 22, 2012 03:32
-
-
Save girvan/2155423 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> | |
<script> | |
$(document).ready(function(){ | |
var tpl_html=$('#tpl').html(); | |
$("#main").html(tpl_html); //copy html into new div | |
$("#tpl input[name='xxx']").val('hi'); //set value into input element | |
alert($("#tpl input[name='xxx']").val()); // input element is 'hi' | |
alert($("#tpl").html()); //print #main 's html, where is 'hi' ?? | |
}); | |
</script> | |
</head> | |
<body> | |
<div id='tpl'><input type='input' name='xxx' value='' /></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment