通过jQuery打造支持汉字,拼音,英文快速定位查询的超级select插件

2020-05-18 09:02:10易采站长站整理

});
_self.hover(
function() {
if (getselectvalue(_self.html()) != $(‘#’ + objid).val()) {
mform.find(‘.selectclassdiv’).css({
background: “White”
});
}
$(this).css({
background: “#0080FF”
});
},
function() {
if (getselectvalue(_self.html()) != $(‘#’ + objid).val()) {
$(this).css({
background: “White”
});
}
});
});
}
function getselectvalue(str) {
objid = obj.attr(‘id’);
objid = objid.replace(“selectinput”, “”);
var myid = ”;
$(‘#’ + objid).find(‘option’).each(function() {
if (str == $(this).text()) {
myid = $(this).val();
return false; //跳出循环
//alert(myid);
//
}
});
return myid;
}
function setval(selfhtml) {
objid = obj.attr(‘id’);
objid = objid.replace(“selectinput”, “”);
//alert(selfhtml);
if ($(‘#selectcontent’).length == 0) {
return false;
}
$(‘#’ + objid).attr(‘value’, getselectvalue(selfhtml));
$(‘#’ + selectinputname + objid).val(selfhtml);
};
function getTop(idx) {
var mfontsize;
return idx * 14 – 23;
}
//移动 option div 滚动条
function moveScrollbar(idx) {
if (idx < 1) {
return false;
}
if (idx > ij) {
return false;
}
var t = getTop(idx);
var ch = $(‘#selectcontent’).scrollHeight;
$(‘#selectcontent’).attr(“scrollTop”, t);
// $(‘#selectcontent’).animate({scrollTop : t}, ‘slow’);
$(‘#selectaction’).val($(“#selectclassdiv” + idx).attr(‘rel’));
setval($(“#selectclassdiv” + idx).html());
}
function selectkeyup() {
$(‘#’ + selectinputname + objid).keyup(function(event) {
// alert(ij);
if (ij < selectid) {
selectid = 0;
// return false;
};
if (selectid < 1) {
selectid = 0;
//return false;
};
mfocus = 1;
switch (event.keyCode) {
case 37:
{
mfocus = 0;
creatediv();
$(“#selectclassdiv” + selectid).css({
background: “White”
});
selectid = selectid – 1;
moveScrollbar(selectid);
$(“#selectclassdiv” + selectid).css({
background: “#0080FF”
});
break;
}
case 39:
{
mfocus = 0;
creatediv();
$(“#selectclassdiv” + selectid).css({
background: “White”
});
selectid = selectid + 1;
moveScrollbar(selectid);
$(“#selectclassdiv” + selectid).css({
background: “#0080FF”
});
break;
}
case 40:
{
mfocus = 0;
$(“#selectclassdiv” + selectid).css({
background: “White”
});
selectid = selectid + 1;
moveScrollbar(selectid);