Skip to content

Instantly share code, notes, and snippets.

@girvan
Created March 22, 2012 03:32
Show Gist options
  • Save girvan/2155423 to your computer and use it in GitHub Desktop.
Save girvan/2155423 to your computer and use it in GitHub Desktop.
<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