:
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