900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > jquery监听下拉框选中事件_jQuery实现监听下拉框选中内容发生改变操作示例

jquery监听下拉框选中事件_jQuery实现监听下拉框选中内容发生改变操作示例

时间:2020-08-11 20:50:39

相关推荐

jquery监听下拉框选中事件_jQuery实现监听下拉框选中内容发生改变操作示例

本文实例讲述了jQuery实现监听下拉框选中内容发生改变操作。分享给大家供大家参考,具体如下:

jQuery代码部分:

$(document).ready(function(){

var defaultId = "${defaultSelected}";

var defaultTime = "${timeName}";

$("select option").each(function(){

if($(this).val()==defaultId || $(this).val()==defaultTime){

$(this).attr("selected","selected");

}

});

$("#all").change(function(){

//alert(document.getElementById("allItem").selected);

if(document.getElementById("allItem").selected == true){

$("#timeText").hide();

$("#timeSelect").hide();

}else{

$("#timeText").show();

$("#timeSelect").show();

}

});

});

HTML部分:

Select a project:

${pi.key}

All

Select a time horizon:

Last week

Last month

search

希望本文所述对大家jQuery程序设计有所帮助。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。