web前端|js教程
jQuery,模拟select
web前端-js教程
很多时候,美工会觉得默认的select下拉框很难看(特别是右侧的下拉箭头按钮),他们通常喜欢用一个自定义的图标来代替这个按钮。这样就只能用 js + div 来模拟了,倒腾了一番,用jQuery模拟了下,当然网上这种文章也不少,只是懒得去看找
刷访问量网站源码,vscode 高亮开发,说书ubuntu,tomcat jvm变量,sqlite修改默认值,flash 3d 插件,前端现在有什么好的框架,网络爬虫可以分成几类图片,php 重新排序,seo优化总结报表,网站源码上传教程视频教程,php 开发网页模板下载,交易系统 html模板lzw
棋牌 平台 源码,ubuntu网卡技术文档,怎么修改tomcat的服务端口,爬虫框架有几个,高级php软件工程师招聘,seo的本质lzw
*{font-size:12px;line-height:18px;list-style:none;padding:0;margin:0;text-decoration:none;color:#000;border:0}
.page{text-align:center;margin:50px;}
input{border-bottom:solid 1px #ccc;height:18px}
.expand{display:none;position:absolute;width:200px;height:100px;overflow-y:auto;border:solid 1px #ccc};
.expand li{margin:1px 0;background:#fff}
.expand a{text-decoration:none;display:block;padding:0 5px;background:#efefef;margin:1px 0}
.expand a:hover{background:#ff9}
function showExpand(targetId, expandId, expand_class) {
//先关掉其它弹出的层
if (expand_class != undefined) {
$("." + expand_class).hide();
}
//判断是否为IE
var isIE = (! +[1, ]);
var expand = $("#" + expandId);
var target = $("#" + targetId);
var dx = 0;
if (isIE) {
dx = -2;
}
else {
dx = 0;
}
expand.get(0).style.left = target.get(0).getBoundingClientRect().left + dx + "px";
if (isIE) {
dx = 17;
}
else {
dx = 19;
}
expand.get(0).style.top = parseInt(target.get(0).getBoundingClientRect().top) + dx + "px";
expand.show();
//每个li点击时赋值
$("#" + expandId).find("li").each(function (i) {
$(this).show().click(function () {
target.val($(this).text().split( )[1]);
expand.hide();
})
})
}
function search(srcId, expandId) {
var expand = $("#" + expandId);
var src = $("#" + srcId);
var A = expand.find("a");
var v = src.val().toUpperCase();
A.each(function (i) {
if (v.length >= 2) {
if ($(this).text().toUpperCase().indexOf(v) == -1) {
$(this).parent().hide();
}
else {
$(this).parent().show();
}
}
if (v.length <= 0) {
$(this).parent().show();
}
})
src.val(v);
}
$().ready(function(){
$("#txt_city").keyup(function(){
search( xt_city,city_select1);
}).focus(function(){
showExpand( xt_city,city_select1,expand)
})
$("#txt_city2").keyup(function(){
search( xt_city2,city_select2);
}).focus(function(){
showExpand( xt_city2,city_select2,expand)
})
})
function fnTest(){
document.getElementById("txtTarget").value = document.getElementById("txtSrc").value;
}
网站源码能卖吗,ubuntu网卡不启动,爬虫抓取youtube评论,uproxy php,淘宝seo又叫lzw
href="#" onclick="showExpand( xt_city,city_select1,expand)">▼
SH 上海
BJ 北京
HZ 杭州
WH 武汉
NJ 南京
WX 无锡
href=”#” onclick=”showExpand(‘txt_city2′,’city_select2′,’expand’)”>▼
CN 中文
EN 英语
JP 日本
RA 俄语
FA 法语
00 其它
无图无真相,真相在此:
不足之处:1、按键盘上下键时,没有高亮的自动移动
2、键入文字自动过滤结果时,感觉相对原生的select有些不自然