selected selector in jQuery with example

selected selector returns all selected input elements.

Example :

    <title>selected Selector</title>
    <script type="text/javascript" src=""> </script>
    <script type="text/javascript">
    $("select option:selected").css("color", "Red");
    <select name="players" multiple="multiple">
    <option selected="selected">Messi</option>
    <option selected="selected">Luiz</option>
    <button id="myButton">Click</button>
    <button onclick="location.reload()">Reset</button>

Demo :

In the above example, we have used selected selector. Selected selector returns all selected input elements. In above example, it selects the selected options and applies CSS to it.


Post a Comment