Use jquery to resolve option disable properties that IE does not support _jquery

Source: Internet
Author: User

In IE browser, it is useless to set the Disable property for select options.

A certain means must be adopted to solve the problem. The principle, of course, is to remember the option that was last selected.
This.selectedindex came in handy.
Need to refresh to see the effect, because the output is text, there is no JS load situation.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <title> using jquery to resolve option disable attributes that IE does not support & lt;/title> <meta http-equiv= "Content-type" content= "text/html"; charset=gb2312 "/> <script src= http://img.jb51.net/jslib/jquery/jquery-1.3.2.min.js" type= "Text/javascript" ></script> <script> $ (document). Ready (function () {$ (". Myselect option:disabled"). CSS (' color ', ' #CCC ' ); $ ('. Myselect '). Change (function () {if (this[this.selectedindex].disabled) {This.selectedindex = this.s| | 0; }else{THIS.S = this.selectedindex| | 0; }}) </script> </pead> <body> <p> using jquery to resolve IE unsupported option disable Properties </p> General: < select> <option> 1th </option> <option disabled= "Disabled" > 2nd item </option> <option > 3rd </option> <option disabled= "Disabled" > 4th </option> <option > 5th </option> <option > 6th Item </ option> </select> comparison 1: <select class= "Myselect" > <option> 1th </option> <option disabled= "Disabled" > 2nd </option> <option> 3rd item </option> <option disabled= "Disabled" > 4th </option> <option > 5th </option> <option > 6th Item </option> </select> comparison 2: Select class= "Myselect" > <option> 1th </option> <option disabled= "Disabled" > 2nd item &LT;/OPTION&G T <option> 3rd </option> <option disabled= "Disabled" > 4th </option> <option > 5th </opt ion> <option > 6th </option> </select> <p >dev by Cssrain, of course you are interested, can also be encapsulated into plug-ins. Remember to send me a copy OH. </p> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.