JQuery Plug-In Shields a single element and prevents users from clicking

Source: Internet
Author: User

Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> </title>
<Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type = "text/javascript"> </script>
<Script type = "text/javascript">
// The following plug-ins are recommended to be stored in the js file for convenient calling.
// -------------- Begin ------------------
(Function ($ ){
// Shielding, suitable for a single element.
$. Fn. mask = function (){
Var divHtml = '<div class = "divMask" style = "position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; background: # fff; opacity: 0; filter: alpha (opacity = 0) "> </div> ';
$ (This). wrap ('<span style = "position: relative"> </span> ');
$ (This). parent (). append (divHtml );
$ (This). data ("mask", "true ");
}
// Unblocking
$. Fn. unmask = function (){
$ (This). parent (). find (". divMask"). remove ();
$ (This). unwrap ();
$ (This). data ("mask", "false ");
}
}) (JQuery );
// -------------- Plug-in end ------------------
// No disabled processing is performed, but a screen layer is added to it to make it unavailable.
// This makes it easier to handle other tasks.
Function changeA2 (obj ){
Var t = {'key': 'B', 'value': '2'}; // ing
If (obj. value = t. key ){
$ ("# A2"). val (t. value );
$ ("# A2"). mask ();
} Else {
$ ("# A2"). val ("");
$ ("# A2"). unmask ();
}
}
</Script>
</Head>
<Body>
<Select name = "A1" id = "A1" onchange = "changeA2 (this)">
<Option value = ""> -- select -- </option>
<Option value = "a"> a </option>
<Option value = "B"> B </option>
<Option value = "c"> c </option>
<Option value = "d"> d </option>
</Select>
<Select name = "A2" id = "A2">
<Option value = ""> -- select -- </option>
<Option value = "1"> 1 </option>
<Option value = "2"> 2 </option>
<Option value = "3"> 3 </option>
<Option value = "4"> 4 </option>
</Select>
</Body>
</Html>

Related Article

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.