text selector in jQuery with example



text selector returns all input elements with type text.


Example :



    <html>
    <head>
    <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">
    $(document).ready(function()
    {
    $("#myButton").click(function()
    {
    $(":text").css({'font-family':'Comic sans ms','font-weight':'bold'});
    });
    });
    </script>
    </head>
    <body>
    <input type="text" id="text1" Value="This is textbox">
    <button id="myButton">Click Me</button>
    <button onclick="location.reload()">Reset</button>
    </body>
    </html>
    

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.

0 comments:

Post a Comment