$(document).ready( function(){ alert('the jquery is loading'); // to get/set the form fields value we use val() var x= $("#mytext").val(); //alert("printing the text box value: "+x); //alert("now lets see how to set the text box value"); //onclick event for the button and when u click on it will change the css value. $("#mychange").click(function(){ $("#mytext").val("sudheer world"); }); });
<input type="text" value="hello world" id="mytext"><br> <input type="button" id="mychange" value="changevalue"> <p id="mypid"> this is my text </p>