element selector in jQuery with example



element selector returns all the element with the specified element name.



Example :




    <html>
    <head>
    <title>Element 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()
    {
    $("button").click(function()
    {
    $("div").css({'font-size':'20px','background-color':'Orange'});
    });
    });
    </script>
    </head>
    <body>
    <div>This is div.</div>
    <button>Click Me</button>
    <button onclick="location.reload()">Reset</button>
    </body>
    </html>
    

Demo :





In the above example, we have used element selector. Element selector selects all the elements with the specified element. In above example, it selects the div element and applies CSS to it.

0 comments:

Post a Comment