jquery Plugin Implementation masks Individual elements so users cannot click _jquery

Source: Internet
Author: User
Copy Code code as follows:

<! DOCTYPE html>
<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 in the JS file to facilitate the call
--------------Plugin begin------------------
(function ($) {
masks, suitable for individual elements.
$.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");
}
Remove Mask
$.fn.unmask = function () {
$ (this). Parent (). Find (". Divmask"). Remove ();
$ (this). Unwrap ();
$ (this). Data ("Mask", "false");
}
}) (JQuery);
--------------Plug-in End------------------
Did not do disabled processing, just add a shield layer above, make it cannot point to just.
This makes it more convenient for other places to be treated without further treatment.
function changeA2 (obj) {
var t = {' key ': ' B ', ' Value ': ' 2 '};//mapping corresponding relationship
if (Obj.value = = T.key) {
$ ("#A2"). Val (T.value);
$ ("#A2"). Mask ();
} else {
$ ("#A2"). Val ("");
$ ("#A2"). unmask ();
}
}
</script>
<body>
<select name= "A1" id= "A1" onchange= "changeA2" (This) >
<option value= "" >--Please choose--</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= "" >--Please choose--</option>
<option value= "1" >1</option>
<option value= "2" >2</option>
<option value= "3" >3</option>
<option value= "4" >4</option>
</select>
</body>

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.