Thursday, September 27, 2012

jQuery : Add title to dropdown select option.

jQuery : Add title to dropdown select option.

This very easy demo will show you how to add title to all of select option in page.
Demo Code show below.

Please select your item in dropdown to view title result.

Source code below this text

        <select>
            <option>FIRST Option</option>
            <option>SECOND Option</option>
            <option>THIRD Option</option>
            <option>Fourth Option</option>
            <option>FIFTH Option</option>
            <option>SIXTH Option</option>
        </select>
        <script type="text/javascript">
            $(document).ready(function () {
                $("option").each(function () {
                    this.setAttribute('title', this.innerText);
                });
            });
        </script>
    

Don't hesitate to contact me zomdev.

No comments:

Post a Comment