<div id="form">
<form action="">
<input type="button" id="sub"/>
</form>
</div>
When clicking the submit button content will be changed using jquery.
Jquery code:
$(document).ready(function() {
$('#sub').live('click', function() {
var reg = "<form action=''><input type='text' id='text'/><input type='button' is='sub2'/></form>";
$('#form').replaceWith(reg);
});
});
$(document).ready(function() {
$('#sub2').live('click', function() {
$('#text').text("Some content");
});
});
But my problem is the content does not get written into input box. How can i do that plz help? Also how to change the background color of input box with id text?
You need to call
val()instead oftext()as text() is not defined for input type of text.