file selector in jQuery with example



file selector returns all input elements with type file.


Example :




    <html>
    <head>
    <title>file 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()
    {
    $(":file").css("background-color","Orange");
    });
    });
    </script>
    </head>
    <body>
    <input type="file">
    <button type="button" id="myButton">Click Me</button>
    <button onclick="location.reload()">Reset</button>
    </body>
    </html>
    

Demo :





        In the above example, we have used file selector. File selector returns all input elements with type file. In above example, it selects the file element and applies CSS to it.

0 comments:

Post a Comment