text selector in jQuery with example

text selector returns all input elements with type text.

Example :

    <title>text Selector</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
    <script type="text/javascript">
    $(":text").css({'font-family':'Comic sans ms','font-weight':'bold'});
    <input type="text" id="text1" Value="This is textbox">
    <button id="myButton">Click Me</button>
    <button onclick="location.reload()">Reset</button>

Demo :

In the above example, we have used text selector. Text selector return all input elements with type text. In the above example the text selector selects the textbox element and changes font-family of the text.


Post a Comment