Motyar

@motyar

Freelance Web Developer

Static Web Hosting, made easy

Jul 23, 2010

Jquery textbox value

If you think you are a master of Jquery, you may skip this post and should take a look at other rocking posts. Because i am writing this post for the jquery beginners they are searching google for the term "Jquery textbox value". So if you came from a search engine, you are welcome here.



Idea

I was playing with the google adwords and found that "Jquery texbox value" is a good keyword for a blog post. You should also use this tool.

I think you are just confused!! naah??. Dont worry, here is a simple solution of your problem. If you found it useful please leave a comment with codeword MOTYAR.

Have you tried - .val() ??

Code


 <div style="padding:16px;">

    TextBox : <input type="textbox" value="Type something" id="textbox"></input>

</div>


<button id="Get">Get TextBox Value</button> 

<button id="Set">Set To "MOTYAR"</button> 


<button id="Reset">Reset It</button>


<h4>TextBox value : <label id="msg"></label></h4>

 

<script type="text/javascript">


    $("#Get").click(function () {

 

    $("#msg").html($("#textbox").val());


 

    });

 

    $("#Reset").click(function () {

 

    $("#msg").html("");


    $("#textbox").val("");


    });

 
    $("#Set").click(function () {


    $("#textbox").val("MOTYAR");

    $("#msg").html($("#textbox").val());

    });
 
</script> 


Demo



You can see the working demo here.

Download

You also can download the code from here.

Labels: ,




By :