selectjquery下拉框选中事件某一站点时,触发事件

我想问一下如何去触发下拉框下拉事件,就是当点击一个按钮触发一个事件,使下拉框下拉框下拉出数据
onchange 事件 送你一些操作select的方法
&select onchange="" id="objSelect"&
// 设置select中value="paraValue"的Item为选中&&&
document.all.objSelect.value = objItemV&&&
// 得到select的当前选中项的value&&&
var currSelectValue = document.all.objSelect.&&&
// 得到select的当前选中项的text&&&
var currSelectText = document.all.objSelect.options[document.all.objSelect.selectedIndex].&&&
// 得到select的当前选中项的Index&&&
var currSelectIndex = document.all.objSelect.selectedI&&&
// 清空select的项&&&
document.all.objSelect.options.length = 0;&
已解决问题
未解决问题jquery操作select下拉框的多种方法(选中,取值,赋值等)43
上亿文档资料,等你来发现
jquery操作select下拉框的多种方法(选中,取值,赋值等)43
Query获取Select选择的Text和Val;语法解释:;1.$(&#select_id&quo;2.varcheckText=$(&#;3.varcheckValue=$(&;4.varcheckIndex=$(&;5.varmaxIndex=$(&#s;jQuery设置Select选择的Text和Va
Query获取Select选择的Text和Value:语法解释:1. $(&#select_id&).change(function(){//code...});
//为Select添加事件,当选择其中一项时触发2. var checkText=$(&#select_id&).find(&option:selected&).text();
//获取Select选择的Text3. var checkValue=$(&#select_id&).val();
//获取Select选择的Value4. var checkIndex=$(&#select_id &).get(0).selectedI
//获取Select选择的索引值5. var maxIndex=$(&#select_id option:last&).attr(&index&);
//获取Select最大的索引值jQuery设置Select选择的 Text和Value:语法解释:1. $(&#select_id &).get(0).selectedIndex=1;
//设置Select索引值为1的项选中2. $(&#select_id &).val(4);
// 设置Select的Value值为4的项选中3. $(&#select_id option[text='jQuery']&).attr(&selected&, true);
//设置Select的Text值为jQuery的项选中jQuery添加/删除Select的Option项:语法解释:1. $(&#select_id&).append(&&option value='Value'&Text&/option&&);
//为Select追加一个Option(下拉项)2. $(&#select_id&).prepend(&&option value='0'&请选择&/option&&);
//为Select插入一个Option(第一个位置)3. $(&#select_id option:last&).remove();
//删除Select中索引值最大Option(最后一个)4. $(&#select_id option[index='0']&).remove();
//删除Select中索引值为0的Option(第一个)5. $(&#select_id option[value='3']&).remove();
//删除Select中Value='3'的Option5. $(&#select_id option[text='4']&).remove();
//删除Select中Text='4'的Optionjquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关获 取一组radio被选中项的值var item = $('input[@name=items][@checked]').val();获 取select被选中项的文本var item = $(&select[@name=items] option[@selected]&).text();select下拉框的第二个元素为当前选中值$('#select_id')[0].selectedIndex = 1;radio单选组的第二个元素为当前选中值$('input[@name=items]').get(1).checked = 获取值: 文本框,文本区域:$(&#txt&).attr(&value&);多选框 checkbox:$(&#checkbox_id&).attr(&value&);单选组radio:
$(&input[@type=radio][@checked]&).val();下拉框select: $('#sel').val(); 控制表单元素:文本框,文本区域:$(&#txt&).attr(&value&,'');//清空内容$(&#txt&).attr(&value&,'11');//填充内容 多选框checkbox: $(&#chk1&).attr(&checked&,'');//不打勾$(&#chk2&).attr(&checked&,true);//打勾if($(&#chk1&).attr('checked')==undefined) //判断是否已经打勾 单选组 radio:
$(&input[@type=radio]&).attr(&checked&,'2');//设置value=2的项目为当前选中项下拉框 select:
$(&#sel&).attr(&value&,'-sel3');//设置value=-sel3的项目为当前选中项$(&&option value='1'&1111&/option&&option value='2'&2222&/option&&).appendTo(&#sel&)//添加下拉框的option$(&#sel&).empty();//清空下拉框---------------------------------------------------------------------------------------------------- //遍历option和添加、移除optionfunction changeShipMethod(shipping){var len = $(&select[@name=ISHIPTYPE] option&).lengthif(shipping.value != &CA&){$(&select[@name=ISHIPTYPE] option&).each(function(){if($(this).val() == 111){$(this).remove();}});}else{$(&&option value='111'&UPS Ground&/option&&).appendTo($(&select[@name=ISHIPTYPE]&));}} //取得下拉x蔚倪x取值$(#testSelect option:selected').text();或$(&#testSelect&).find('option:selected').text();或$(&#testSelect&).val();//////////////////////////////////////////////////////////////////记 性不好的可以收藏下:1,下拉框:var cc1 = $(&.formc select[@name='country'] option[@selected]&).text(); //得到下拉菜单的选中项的文本(注意中间有空格)var cc2 = $('.formc select[@name=&country&]').val(); //得到下拉菜单的选中项的值 var cc3 = $('.formc select[@name=&country&]').attr(&id&); //得到下拉菜单的选中项的ID属性值$(&#select&).empty();//清空下拉框 //$(&#select&).html('');$(&&option value='1'&1111&/option&&).appendTo(&#select&)//添加下拉框的option 稍微解释一下:1.select[@name='country'] option[@selected] 表示具有name 属性,并 且该属性值为'country' 的select元素 里面的具有selected 属性的option 元素; 可以看出有@开头的就表示后面跟 的是属性。2,单选框:$(&input[@type=radio][@checked]&).val(); //得到单选框的 选中项的值(注意中间没有空格)$(&input[@type=radio][@value=2]&).attr(&checked&,'checked'); //设置单选框value=2的为选中状态.(注意中间没有空格)3,复选框:$(&input[@type=checkbox][@checked]&).val(); //得到复选框的选中的第一项的值$(&input[@type=checkbox][@checked]&).each(function() { //由于复选框一般选中的是多个,所以可以循环输出alert($(this).val());});$(&#chk1&).attr(&checked&,'');//不打勾$(&#chk2&).attr(&checked&,true);// 打勾if($(&#chk1&).attr('checked')==undefined){} //判断是否已经打勾 当然jquery的选择器是强大的. 还有很多方法.&script src=&jquery-1.2.1.js& type=&text/javascript&&&/script&&script language=&javascript& type=&text/javascript&&$(document).ready(function(){$(&#selectTest&).change(function(){//alert(&Hello&);//alert($(&#selectTest&).attr(&name&));//$(&a&).attr(&href&,&xx.html&);//window.location.href=&xx.html&;//alert($(&#selectTest&).val());alert($(&#selectTest option[@selected]&).text());$(&#selectTest&).attr(&value&, &2&);});});&/script& &a href=&#&&aaass&/a&&!--下拉框--&&select id=&selectTest& name=&selectTest&&&option value=&1&&11&/option&&option value=&2&&22&/option&&option value=&3&&33&/option&&option value=&4&&44&/option&&option value=&5&&55&/option&&option value=&6&&66&/option&&/select&jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关获取一组radio被选中 项的值var item = $('input[@name=items][@checked]').val();获取select被选 中项的文本var item = $(&select[@name=items] option[@selected]&).text();select 下拉框的第二个元素为当前选中值$('#select_id')[0].selectedIndex = 1;radio单选组的第二个 元素为当前选中值$('input[@name=items]').get(1).checked =获取值:文本 框,文本区域:$(&#txt&).attr(&value&);多选框 checkbox:$(&#checkbox_id&).attr(&value&);单选组radio: $(&input[@type=radio][@checked]&).val();下拉框select: $('#sel').val();控 制表单元素:文本框,文本区域:$(&#txt&).attr(&value&,'');//清空内容$(&#txt&).attr(&value&,'11');// 填充内容多选框checkbox: $(&#chk1&).attr(&checked&,'');//不打勾$(&#chk2&).attr(&checked&,true);// 打勾if($(&#chk1&).attr('checked')==undefined) //判断是否已经打勾单选组radio: $(&input[@type=radio]&).attr(&checked&,'2');//设置value=2的项目为当前选中项下拉框 select: $(&#sel&).attr(&value&,'-sel3');//设置value=-sel3的项目为当前选中项$(&&optionvalue='1'&1111&/option&&optionvalue='2'&2222&/option&&).appendTo(&#sel&)//添加下拉框的option$(&#sel&).empty();// 清空下拉框获取一组radio被选中项的值var item = $('input[@name=items][@checked]').val();获取select被选中项的文本var item = $(&select[@name=items] option[@selected]&).text();select下拉框的第二个元素为当 前选中值$('#select_id')[0].selectedIndex = 1;radio单选组的第二个元素为当前选中值$('input[@name=items]').get(1).checked =获取值:文本框,文本区域:$(&#txt&).attr(&value&);多选框 checkbox:$(&#checkbox_id&).attr(&value&);单选组radio: $(&input[@type=radio][@checked]&).val();下拉框select: $('#sel').val();控 制表单元素:文本框,文本区域:$(&#txt&).attr(&value&,'');//清空内容$(&#txt&).attr(&value&,'11');// 填充内容多选框checkbox: $(&#chk1&).attr(&checked&,'');//不打勾$(&#chk2&).attr(&checked&,true);// 打勾if($(&#chk1&).attr('checked')==undefined) //判断是否已经打勾单选组radio: $(&input[@type=radio]&).attr(&checked&,'2');//设置value=2的项目为当前选中项下拉框 select: $(&#sel&).attr(&value&,'-sel3');//设置value=-sel3的项目为当前选中项$(&&option value='1'&1111&/option&&option value='2'&2222&/option&&).appendTo(&#sel&)//添加下拉框的option$(&#sel&).empty();// 清空下拉框 转载太多次,原作者已不可考,感谢原作者的贡献,以及k686绿色软件(/)的供稿包含各类专业文献、幼儿教育、小学教育、专业论文、文学作品欣赏、各类资格考试、外语学习资料、jquery操作select下拉框的多种方法(选中,取值,赋值等)43等内容。
 jquery 获取当前选中的下拉框的, 如 select text,value,indext 下面先介绍了很多 jquery 获取 select 属性的方法, 同时后面的实例我们讲的是 jquery 获取下拉框值...  jQuery对表单元素的取值和赋值操作_IT/计算机_专业资料。转:jQuery 对表单元素的...(); select 下拉框的第二个元素为当前选中值 $('#select_id')[0]....  jQuery 取值、赋值的基本方法_计算机软件及应用_IT/...select下拉框的第二个元素为当前选中值 $('#select...给一个元素设置属性 $(”#myid”).attr(”width...  下拉框 SELECT 选项的多种方法来源:互联网 作者:...文件末尾加上一段脚本为下拉框赋值:复制代码 代码如...jquery操作select下拉框... 5页 免费 传统的HTML页面...  Jquery 表单取值赋值的一些基本操作 1: JQUERY 找无...得到下拉菜单的选中项的 ID 属性值 $(&#select&)...{ //由于复选框一般选中的是多个,所以可以 循环...  jQuery 对 select 操作 //遍历 option 和添加、...//取得下拉选单的选取值 $(#testSelect option:selected...{ //由于复选框 一般选中的是多个,所以可以循环...  jquery radio 取值,checkbox 取值,select 取值,radio...select 下拉框的第二个元素为当前选中值 :$('#...还有很多方法. &script src=&jquery-1.2.1.js&...  jquery radio 取值,checkbox 取值,select 取值,radio...(); select 下拉框的第二个元素为当前选中值 $(...(); 下拉框 select: $('#sel').val(); 控制...  Jquery给基本控件的取值赋值_计算机软件及应用_IT/计算机...设置 value=2 的项目为当前选中项 //下拉框 ...(); select 下拉框的第二个元素为当前选中值 $(...当前访客身份:游客 [
这个人很懒,啥也没写
目前还没有任何评论
今日访问:0
昨日访问:2
本周访问:12
本月访问:25
所有访问:1632
自定义弹出窗口,实现可输入可过滤自动选择下拉框
发表于10个月前( 08:32)&&
阅读(460)&|&评论()
0人收藏此文章,
自定义弹出窗口,实现可输入可过滤自动下拉框值兼容各种IE版本 firefox chrome等, 这里不多说了 直接上代码。。。。。。。
jQuery dialog windows *
author : piyg
Copyright(c) :
Version 1.0-pre
自定义定时定频弹出窗口; 用法: 在自身jsp页面调用 showDialog(title,fn1,fn2),showProcessDialog(title,fn1,fn2)方法。 title: 自定义窗口头信息。 fn1 ,fn2 自定义回调函数,分别绑定2个按钮事件 fn1: ”继续提交“按钮事件。 fn2: ”修改执行日期“按钮事件。 **/ var window = window.parent || window. var document = window.parent.document || window.
$(document).ready(function(){
var css=jQuery(_document.getElementsByTagName(“head”)[0]).append(“ “);
css=jQuery(_document.getElementsByTagName("head")[0]).children(":last");
css.attr({
type:"text/css",
rel:"stylesheet",
href:"../../css6/jquery.dialog.css"
var divHtml=' &div id="main" onselectstart="return false" oncontextmenu="return false"&&div id="header"&来自网页的消息 &img
src="../../images6/winClose.png" alt="" id=\"warnClose\" /&&/div& '+
' &div id="warn" &&img
src="../../images6/warn.png" alt="" class="warnIcon" /&&/div& '+
' &div id="content"& &span id="txt"&若实际天数小于设定的执行日期,则当月不执行预约交易。若需每天最后一个工作日执行,请将执行日期设置为"32" 。&/span&&/div& '+
' &div id="footer"&&div id="submit"&&input
type="button" id="submitBtn"
name="submitBtn" value="继续提交" /& &/div& '+
' &div id="back"&&input type="button" id="backBtn"
name="backBtn" value="修改执行日期" /&&/div&&/div&&/div& ';
var divFlow=' &div id="inner" onselectstart="return false" oncontextmenu="return false"&&div id="headTitle"&来自网页的消息 &img
src="../../images6/winClose.png" alt="" id=\"helpClose\" /&&/div& '+
' &div id="help" &&img
src="../../images6/help.png" alt="" class="helpIcon" /&&/div& '+
' &div id="text"& &span id="description"&&&&该流程尚有未完成单据,请选择流程删除后未完成单据的处理方式。&/span&&/div& '+
' &div id="foot"&&div id="btn"&&input
type="button" id="delBtn"
name="delBtn" value="全部删除" /&'+
' &input type="button" id="execBtn"
name="execBtn" value="继续执行" /&&/div&'+
' &div id="other"& '+
'&p id="remark"& '+
'&&&注:点击“全部删除”,修改流程同时删除未完成的单据,原未完成单据不再执行,点击“继续执行",只修改流程,不删除除未完成单据,未完成单据仍按原流程执行。 &/p&'+
'&/div&&/div&'
//var div= '&div id="warpDiv" style="display: filter: alpha(opacity=40); opacity: 40; "&&/div&';
jQuery(_document.getElementsByTagName("body")[0]).append(divHtml).append(divFlow);
var warpDiv = _document.createElement("div");
warpDiv.setAttribute("id","warpDiv");
warpDiv.style.cssText = "display: filter: alpha(opacity=10); opacity: 0.1; ";
_document.getElementsByTagName("body")[0].appendChild(warpDiv);
//jQuery(_window.document.body).append(div);
startDarg(_document.getElementById("headTitle"),_document.getElementById("inner"));
startDarg(_document.getElementById("header"),_document.getElementById("main"));
function showDialog(title,fn1,fn2){
var mainDiv=_document.getElementById("main");
var headerDiv=_document.getElementById("header");
if(typeof title !="undefined"){
headerDiv.innerHTML=title+'&img
src="../../images6/winClose.png" alt="" id="warnClose" /& ';
if(getStyle(mainDiv,"display") == "none"){
mainDiv.style.display = "block";
jQuery(document).bind("selectstart contextmenu ", function(){});
divLocal(mainDiv);
bindEvent(_document.getElementById("submitBtn"),_document.getElementById("backBtn"),fn1, fn2);
function showProcessDialog(title,fn1,fn2){
var innerDiv=_document.getElementById("inner");
var headDiv=_document.getElementById("headTitle");
if(typeof title !="undefined"){
headDiv.innerHTML=title+'&img
src="../../images6/winClose.png" alt="" id="helpClose" /& ';
if(getStyle(innerDiv,"display") == "none"){
innerDiv.style.display = "block";
jQuery(_document).bind("selectstart contextmenu ", function(){});
divLocal(innerDiv);
bindEvent(_document.getElementById("delBtn"),_document.getElementById("execBtn"),fn1, fn2);
function divLocal(obj){
var warpDiv=_document.getElementById("warpDiv");
var srceenSize = getScreen();
var centerSrceen = getCenter(obj);
if(warpDiv.style.display == "none"){
warpDiv.style.display = "block";
warpDiv.style.width = srceenSize.width +'px';
warpDiv.style.height = srceenSize.height + 'px';
obj.style.top = centerSrceen.top +'px';
obj.style.left = centerSrceen.left + 'px';
function getStyle(obj,attr){
return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj,null)[attr] ;
function getCenter(element){
var left ,
if(_window.innerHeight || _window.innerWidth){
top = _window.innerHeight/2
+ (_document.documentElement.scrollTop|| _document.body.scrollTop) - element.offsetHeight/2;
left = _window.innerWidth/2 + (_document.documentElement.scrollLeft || _document.body.scrollLeft) - element.offsetWidth/2;
left = _document.documentElement.offsetWidth/2 + (_document.documentElement.scrollLeft || _document.body.scrollLeft) - element.offsetWidth/2;
_document.documentElement.offsetHeight/2 + (_document.documentElement.scrollTop || _document.body.scrollTop) - element.offsetWidth/2
left: left,
function getScreen(){
var height,
if(_window.innerHeight || _window.innerWidth){
height = _window.innerHeight +
_document.documentElement.scrollTop || _document.body.scrollT
width = _window.innerWidth +
_document.documentElement.scrollLeft || _document.body.scrollL
height = (_document.documentElement.offsetHeight || _document.body.offsetHeight) + (_document.documentElement.scrollTop || _document.body.scrollTop) ;
width = (_document.documentElement.offsetWidth || _document.body.offsetWidth) + (_document.documentElement.scrollLeft || _document.body.scrollLeft );
height: height,
width: width
function startDarg(sideBar, dargDiv){
sideBar.onmousedown = function(e){
var ev = e || _window.
var disX = ev.clientX - dargDiv.offsetL
var disY = ev.clientY - dargDiv.offsetT
_document.onmousemove=function(e){
var ev = e || _window.
l = ev.clientX - disX;
t = ev.clientY - disY;
if(l & 0) l = 0;
if(t & 0) t = 0;
if(l & _document.documentElement.clientWidth + _document.documentElement.scrollLeft- dargDiv.offsetWidth){
l = _document.documentElement.clientWidth + _document.documentElement.scrollLeft - dargDiv.offsetW
if(t & _document.documentElement.clientHeight + _document.documentElement.scrollTop - dargDiv.offsetHeight){
t = _document.documentElement.clientHeight + _document.documentElement.scrollTop -
dargDiv.offsetH
dargDiv.style.left = l + 'px';
dargDiv.style.top = t + 'px';
_document.onmouseup=function(e){
_document.onmousemove =
_document.onmouseup =
if(sideBar.releaseCapture){
sideBar.releaseCapture();
if(sideBar.setCapture){
sideBar.setCapture();
function bindEvent(btn1,btn2,fn1, fn2){
//var submitBtn = document.getElementById("submitBtn");
//var backBtn = document.getElementById("backBtn");
jQuery(btn1).off("click");
jQuery(btn2).off("click");
if(typeof fn1 == "undefined"){
jQuery(btn1).on("click", function(){
document.forms[0].submit();
closeDialog();
jQuery(btn1).on("click",fn1);
if(typeof fn2 == "undefined"){
jQuery(btn2).on("click", function(){
closeDialog();
jQuery(btn2).on("click", fn2);
jQuery(_document.getElementById("helpClose")).on("click", function(){
closeDialog();
jQuery(_document.getElementById("warnClose")).on("click", function(){
closeDialog();
function closeDialog(){
var mainDiv = _document.getElementById("main");
var warpDiv = _document.getElementById("warpDiv");
var innerDiv = _document.getElementById("inner");
jQuery(_document).unbind("selectstart contextmenu");
if(mainDiv.style.display == "block"){
mainDiv.style.display = "none";
if(innerDiv.style.display == "block"){
innerDiv.style.display = "none";
if(warpDiv.style.display == "block"){
warpDiv.style.display = "none";
jQuery select box Tags *
author : piyg
Copyright(c) :
Version 1.0-pre *
对于下拉框选择值后需做特殊处理时,请在自身的jsp页面实现dataHandler函数,如:function dataHandler(id,txt,sid){};
id:下拉框选项id属性值,txt:下拉框选项文本值,sid:文本下拉框id属性值,用于判断为某一个文本下拉框选项动态绑定click事件。
该函数功能类似于select标签的 onchange事件功能;
优化下拉框,去掉自身jsp页面标签;
filter :增加文本属性标识是否进行过滤筛选下拉框值;去掉自身jsp页面标签;
对实现下拉框增加class=“select-box”,dataSrc=“json数据源” 的属性值,对应隐藏域id属性值为可输入可选择下拉框id属性值的前缀加上hidden_*。
注: 调用 jquery.select.js 函数库的所有方法时需要前缀添加 自定义命令空间 如(selectBoxTool . renderOption(cityData,“city”); )
防止与其他同名函数冲突;
实现一个可输入可选择文本下拉框 页面代码如下:
//为了兼容IE6浏览器 //采用iframe嵌套div层方式防止dom自身下拉框层覆盖自定义可输可选择下拉框。 Math.max.apply(null array);
var $$B = {ie6:isCurrIE6};
if($$B.ie6) document.write('');
//动态加载自定义下拉框层叠样式表: var guid=““;
var count=0; //是否存在匹配元素 $(document).ready(function(){
var css=jQuery("head").append("&link&");
css=jQuery("head").children(":last");
css.attr({
type:"text/css",
rel:"stylesheet",
href:"../../css6/jquery_select.css"
var selectHtml='&div
id="container" name="container" style="position:display:"&'+
'&ul id="inner" name="inner" class="inner_select"&&/ul&&/div&';
//记住li选择的位置
jQuery("form").append('&input type="hidden" id="selectId" value=""&');
jQuery("body").append(selectHtml);
jQuery(".select_box").each(function(i){
jQuery(this).after("&i id=search"+i+" name='search' class='icon_search'&&/i&");
jQuery(this).next(".icon_search").click(function(){
selectBoxTool.selectData(jQuery(".select_box")[i].id,false);
var filter = jQuery(".select_box")[i].getAttribute("filter");
if("true" == filter){
jQuery(this).click(function(){
selectBoxTool.selectData(jQuery(this)[0].id,true);
jQuery(this).keyup(function(){
selectBoxTool.selectDataKey(jQuery(this)[0].id,true);
jQuery(this).keyup(function(){
selectBoxTool.searchData(jQuery(this)[0].id,jQuery(this)[0].value);
selectBoxTool.inputChange(jQuery(".select_box")[i].id);
selectBoxTool.inputChange(jQuery(".icon_search")[i].id);
//初始化下拉文本框宽度大小 $(document).ready(function(){
jQuery(".select_box").each(function(i){
var array=[];
//alert(jQuery(".select_box")[i].id);
var jdata=selectBoxTool.checkData(eval(jQuery(".select_box")[i].getAttribute("dataSrc")));
array.push(selectBoxTool.checkLen(jQuery(".select_box")[i].defaultValue));
if(typeof jdata == "object"){
jQuery.each(jdata,function(i){
array.push(selectBoxTool.checkLen(jdata[i].value));
//alert(jdata[i].id);
var maxLength=Math.max.apply(null, array);
jQuery(jQuery(".select_box")[i]).css("width", maxLength * 8 + 10);
//jQuery(".select_box")[i].style['width'] = maxLength*10;
//alert(array);
//定义命名空间 var selectBoxTool = {
initOption : function (jsonData,sid,searchObj,flag){
var ulHtml = "",id = "",value = "",searchTxt = "";
count = 0;
var jdata=selectBoxTool.checkData(jsonData);
for(var i=0,len=jdata. i& i++){
id=jdata[i]['id'];
value=jdata[i]['value'];
if(typeof id == "undefined" && typeof value == "undefined" ){
//alert(value);
if(flag) { //是否进行过滤查询
searchTxt=!searchObj&&searchObj.value==null? "" : searchObj.
if(value.indexOf(searchTxt) !=-1){
ulHtml += "&li id='"+i+"' onmouseover=selectBoxTool.over('"+id+"'); onmouseout=selectBoxTool.out('"+id+"');&&a onclick=\"selectBoxTool.changeTxt('"+id+"','"+value+"','"+sid+"','"+i+"')\"; id='"+id+"'
&"+value+"&/a&&/li&";
ulHtml += "&li id='"+i+"' onmouseover=selectBoxTool.over('"+id+"'); onmouseout=selectBoxTool.out('"+id+"'); &&a onclick=\"selectBoxTool.changeTxt('"+id+"','"+value+"','"+sid+"','"+i+"')\"; id='"+id+"'
&"+value+"&/a&&/li&";
jQuery("#inner").html(ulHtml);
//为级联重新渲染选择器
renderOption :
function(jsonData,sid){
selectBoxTool.initOption(jsonData,sid);
jQuery("#"+sid).val(jQuery("#"+sid)[0].defaultValue);
selectData :
function (sid,flag){
var obj = document.getElementById(sid);
var div = document.getElementById("container");
var jsonData = eval(obj.getAttribute("dataSrc"));
if(div.style.display == 'none'){
selectBoxTool.initOption(jsonData,sid,obj,flag);
selectBoxTool.divPos(div,sid);
jQuery("#container").show("fast");
}else if(div.style.display == '' || div.style.display == 'block'){
jQuery("#container").hide("fast");
jQuery("#container").hide("fast");
selectDataKey :function(sid,flag){
var obj = document.getElementById(sid);
var div = document.getElementById("container");
var jsonData = eval(obj.getAttribute("dataSrc"));
var evt = window.
var ele = evt.srcElement || evt.
if(ele.id == sid){
selectBoxTool.initOption(jsonData,sid,obj,flag);
selectBoxTool.divPos(div,sid);
div.style.display = "block";
div.style.display = "none";
// 文本下拉框属性filter 为false或者空时 在输入文本值时
需要自动对隐藏域自动查找并赋值
searchData : function(sid,srcText){
var obj = document.getElementById(sid);
var data=selectBoxTool.checkData(eval(obj.getAttribute("dataSrc")));
if(typeof data == "object"){
jQuery.each(data,function(i){
var targetText = data[i]['value'];
var targetId = data[i]['id'];
if(targetText == srcText){
jQuery("#hidden_"+sid).val(targetId);
jQuery("#selectId").val(i);
jQuery("#hidden_"+sid).val("");
jQuery("#selectId").val(0);
changeTxt : function(id,txt,sid,index,e){
var div = document.getElementById("container");
var input= document.getElementById(sid);
input.value =
jQuery("#hidden_"+sid).val(id);
//hidden域需特殊处理
jQuery("#selectId").val(index);
var e= e || window.
//每个li标签值绑定click事件,触发事件处于li父元素container上,采用委托事件处理机制, 防止同级多个相同事件源,引起页面不必要的性能问题。
if(typeof(dataHandler) != "undefined"){
dataHandler(id,txt,sid);
//jQuery("#container").one("click","#"+id, {id: id,value:txt}, dataHandler());
if(div.style.display == 'block'||div.style.display == ''){
div.style.display = "none";
div.style.display = 'block';
selectBoxTool.defaultLight(input,false);
input.select();
divPos : function(div,sid){
var ul = document.getElementById("inner");
div.style.top = selectBoxTool.prop(jQuery("#"+sid).offset().top + 24);
div.style.left = selectBoxTool.prop(jQuery("#"+sid).offset().left);
ul.style.width = selectBoxTool.prop(jQuery("#"+sid)[0].clientWidth);
ul.style.height = ($$B.ie6 && count*18 &= 400)? "400px" : "auto";
var uid = jQuery("#hidden_"+sid).val();
var oli = document.getElementById(uid+"");
if(oli!=null){
oli.style.backgroundColor = '#3399ff';
oli.style.color = '#fff';
if($$B.ie6) jQuery("#container").bgiframe();
prop : function(n) {
return n && n.constructor === Number ? n + 'px' :
pgUp : function(){
var index = parseInt(jQuery("#selectId").val(),10);
var opts=document.getElementById(jdata[index].id+"");
if(index == 0){
if(opts!=null) opts.style.backgroundColor = '';
index = index - 1;
if(opts!=null) opts.style.backgroundColor = '#DED';
//jQuery("#"+jdata[index].id).click(changeTxt(jdata[index].id,jdata[index].value,guid,index))
.trigger("click");
selectBoxTool.changeTxt(jdata[index].id,jdata[index].value,guid,index);
pgDn : function(){
var index = parseInt(jQuery("#selectId").val(),10);
var opts=document.getElementById(jdata[index].id+"");
if(index == jdata.length-1){
if(opts!=null) opts.style.backgroundColor = '';
index = index + 1;
if(opts!=null) opts.style.backgroundColor = '#DED';
selectBoxTool.changeTxt(jdata[index].id,jdata[index].value,guid,index);
defaultLight : function(obj,flag){
if(obj!=null && flag){
obj.style.backgroundColor = '#fff';
obj.style.color = '#ccc';
obj.style.backgroundColor = '#fff';
obj.style.color = '#000';
over : function(hid){
var oli=document.getElementById(hid);
if(oli!=null){
oli.style.backgroundColor = '#3399ff';
oli.style.color = '#fff';
out : function(oid){
var oli=document.getElementById(oid);
if(oli!=null){
oli.style.backgroundColor = '#fff';
oli.style.color = '#000';
//判断数据源是否有效
checkData : function(jsonData){
if(typeof jsonData == "string"
jdata = jQuery.parseJSON(jsonData.replace(/[,]+\]}$/g,"]}")).
}else if(typeof jsonData == "undefined" || typeof jsonData.data == "undefined" || jsonData.data == ""){
jdata = "";
jdata = jsonData.
//判断中文为2个字符长度,其他为1个字符长度
checkLen : function(str){
var len=0;
if(typeof str == "undefined"){
for(var n=0;n&str.n++){
var s = str.charAt( n );
if(s.match("[\u4e00-\u9fa5]")){
inputChange : function(tid){
var obj = document.getElementById(tid);
selectBoxTool.defaultLight(obj,true);
if(obj == null){
obj.onfocus=function(){
if(obj.value == obj.defaultValue){
obj.value = "";
selectBoxTool.defaultLight(obj,false);
obj.onblur=function(){
if(obj.value == ""){
obj.value = obj.defaultV
selectBoxTool.defaultLight(obj,true);
if(obj.className == "icon_search"){
obj.onclick=function(){
var div = document.getElementById("container");
var inputTxt = jQuery(obj).prev(".select_box")[0];
if(div.style.display == 'none'||div.style.display == 'block'||div.style.display == ''){
if (inputTxt.value == "") {
inputTxt.value = inputTxt.defaultV
selectBoxTool.defaultLight(obj,true);
}else if(inputTxt.value == inputTxt.defaultValue){
inputTxt.value = "";
selectBoxTool.defaultLight(obj,false);
document.onkeyup = function(e){
var evt = e? e : window.
var ele = evt.srcElement || evt.
var div=document.getElementById("container");
if(div.style.display == '' || div.style.display == 'block'){
switch(evt.keyCode) {
selectBoxTool.pgUp();
selectBoxTool.pgDn();
//alert('回车');
document.onclick = function(e){
var div = document.getElementById("container");
var evt = e? e : window.
var ele = evt.srcElement || evt.
if(ele.id == ''&&(div.style.display=='block'||div.style.display=='')){
var input = jQuery("#"+guid)[0];
jQuery("#container").hide("fast");
if (input.value == "") {
input.value = input.defaultV
CSS样式部分
width: 270
height:190
z-index:5;
-webkit-border-radius: 6px 6px 0px 0
-moz-border-radius: 6px 6px 0px 0
border-radius: 6px 6px 0px 0
background:#
submit #submitBtn{
z-index:5;
font-family:微软雅黑, Tahoma, Geneva, sans-
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#E1EBF3, endColorstr=#ffffff) ;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#E1EBF3), to(#ffffff));
back #backBtn{
width: 100
z-index:5;
font-family:微软雅黑, Tahoma, Geneva, sans-
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#E1EBF3, endColorstr=#ffffff) ;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#E1EBF3), to(#ffffff));
width: 270
line-height:25
background-color:#B8D0E9 ;
z-index:5;
font-family:微软雅黑, Tahoma, Geneva, sans-
color:#000000;
font-size:12.5
width: 258
background-color:#F0F0F0 ;
z-index:5;
border:#B9D1EA 6
border-top:
z-index:5;
background-color:#
height:100
border-left:#D7E5F3 6
.warnIcon {
z-index:5;
width: 194
z-index:5;
background-color:#
padding-top:8
border-right:#D7E5F3 6
width: 194
z-index:5;
background-color:#
font-family:微软雅黑, Tahoma, Geneva, sans-
font-size:13
warnClose{
*+height:18
z-index:5;
width:100%;
*+width: 100%;
z-index:3;
background-color:#
} / 流程删除提醒 弹出对话框 /
width: 320
height:220
z-index:5;
-webkit-border-radius: 6px 6px 0px 0
-moz-border-radius: 6px 6px 0px 0
border-radius: 6px 6px 0px 0
background:#
delete #delBtn{
z-index:5;
font-family:微软雅黑, Tahoma, Geneva, sans-
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#E1EBF3, endColorstr=#ffffff) ;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#E1EBF3), to(#ffffff));
execute #execBtn{
width: 100
z-index:5;
font-family:微软雅黑, Tahoma, Geneva, sans-
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#E1EBF3, endColorstr=#ffffff) ;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#E1EBF3), to(#ffffff));
headTitle{
width: 320
line-height:25
background-color:#B8D0E9 ;
z-index:5;
font-family:微软雅黑, Tahoma, Geneva, sans-
color:#000000;
font-size:12.5
width: 308
background-color:#F0F0F0 ;
z-index:5;
border:#B9D1EA 6
border-top:
width: 308
background-color:#F0F0F0 ;
z-index:5;
font-family:微软雅黑, Tahoma, Geneva, sans-
color:#FB4033;
font-size:12
z-index:5;
background-color:#
height:100
border-left:#D7E5F3 6
.helpIcon {
z-index:5;
width: 234
z-index:5;
background-color:#
padding-top:20
border-right:#D7E5F3 6
description {
width: 180
z-index:5;
background-color:#
font-family:微软雅黑, Tahoma, Geneva, sans-
font-size:13
padding-left:10
helpClose{
*+height:18
z-index:5;
width: 308
z-index:5;
z-index:5;
font-family:微软雅黑, Tahoma, Geneva, sans-
-webkit-border-radius:10
-moz-border-radius:
border-radius:10
background-color:#F2F2F2;
width: 100
z-index:5;
font-family:微软雅黑, Tahoma, Geneva, sans-
-webkit-border-radius:
-moz-border-radius: 10
border-radius:10
background-color:#F2F2F2;
@charset “utf-8”; / CSS Document /
.inner_select{
overflow-y:
border:1px solid #696;
background:#
z-index:9999;
max-height:400
min-height:100
list-style-type:
padding:0;
} .inner_select li{
.inner_select li a{
padding-left:4
line-height:18
text-decoration:
color:#000;
background:#
font-size:14
.inner_select li&a:hover{
text-decoration:
.icon_search{ display:inline- margin-left:-20 margin-top:4 vertical-align: background-image: url(“../images6/bg_select.png”); width:18height:18background-position-x: cursor: position:
实现页面效果如下:
1)">1)">1" ng-class="{current:{{currentPage==page}}}" ng-repeat="page in pages"><li class='page' ng-if="(endIndex<li class='page next' ng-if="(currentPage
相关文章阅读}

我要回帖

更多关于 下拉框选中触发事件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信