// // the Select target Auto Select value extension plugin // author:hotboy// --------------------------------------------------------------------- ----- // (function ($) { $.extend ($.fn, { // AutoSelect: function (Options) { // default options of plugin var defaults = { atr: "Val", filter: "SELECT" } // deep copy $.extend (ISDEEPCOPY,DEFAULT_SRC, Ext1,ext2,ext3,ext4,......); var new_options = $.extend (true, defaults, options); var $this = $ (this); $this. Each (function () { var $t = $ (This); &nbsP; // alert ($t. Prop ("TagName". toLocaleUpperCase ())); if (New_options.filter.toLocaleUpperCase () != $t. Prop ("TagName") { $t. Val ($t. attr (DEFAULTS.ATR)); } }) } }); }) (JQuery);
Front-end invocation mode
Js function
$ (function () {
$ ("tag Selector"). AutoSelect ({ATR: "Checked value Attribute", Filter: "Filters the label type, does not execute bindings,"});
});
==========================================================================================
Example:
Select Label
<select val= "0" >
<option value= "-1" >--Select Gender--</option>
<option value= "0" > Men </option>
<option value= "1" > Women </option>
</Select>
$ (function () {
$ ("Select[val]"). AutoSelect ();
});
===========================================================================================
Here is just a very simple jquery extension demo, hope can help you ~
jquery Implementation Select Automatically selects default values