JQuery Easyui Add the Purge value feature to Combo,combobox

Source: Internet
Author: User

Icon

(function ($) {        //Initialize Clear button     function  Initclear (target) {        var jq = $ (target);         var opts = jq.data (' combo ') .options;         var combo = jq.data (' combo ') .combo;         var arrow = combo.find (' Span.combo-arrow ');                 var clear =  Arrow.siblings ("Span.combo-clear");         if (Clear.size () ==0) {             //Create a purge button.             clear = $ (' <span  class= "Combo-clear"  style= "height: 20px;" ></span> ');                          //the Erase button to add a hover effect.             clear.unbind ("mouseenter.combo  Mouseleave.combo "). Bind (" Mouseenter.combo mouseleave.combo ",                 function (Event) {                     var isenter =  event.type== "MouseEnter";                     clear[isEnter ?  ' addclass '  :  ' Removeclass '] (" Combo-clear-hover ");                 }            );            //the Clear button to add a click event, clear the current selected value and hide the selection panel.             clear.unbind ("Click.combo"). Bind (" Click.combo ", function () {                 jq.combo ("SetValue", ""). Combo ("SetText", "");                 jq.combo (' Hidepanel ');             });             Arrow.before (Clear);        };         var input = combo.find ("Input.combo-text");         input.outerwidth (Input.outerwidth ()-clear.outerwidth ());                 oThe pts.initclear = true;//has been cleared for button initialization.     }        //extension Easyui combo Add clears the current value.     var oldresize = $.fn.combo.methods.resize;    $. Extend ($.fn.combo.methods,{        initclear:function (JQ) {             return jq.each (function () {                  initclear (This);             });         },        resize:function (JQ) {             //calls the default Combo resize method.             var returnValue =  Oldresize.apply (this,arguments);            var opts = jq.data (" Combo "). Options;            if (opts.initClear) {                 jq.combo (" Initclear ", JQ);            }             return returnValue;         }    });} (JQuery));


HTML code <select id= "Myselect" panelheight= "Auto" style= "width:102px" editable= "true" Name= "Itcast" > <optio N value= "0" > Chengdu </option> <option value= "1" > Smart Podcast </option> <option value= "2" > Bill Yao </ Option> <option value= "3" > Little stars </option></select>


JS code $ (' #myselect '). ComboBox ({Required:true,editable:false}). ComboBox ("Initclear");


CSS style. combo-clear {background-color: #E0ECFF;  width:18px;  height:20px;  Overflow:hidden;  Display:inline-block;  Vertical-align:top;  Cursor:pointer;  opacity:0.6;  Filter:alpha (opacity=60); Background:url (' images/combo_clear.png ') No-repeat Center Center;}.  combo-clear-hover {opacity:1.0;  Filter:alpha (opacity=100); Background-color: #eaf2ff;}












JQuery Easyui Add the Purge value feature to Combo,combobox

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.