jQuery實現(xiàn)監(jiān)聽下拉框選中內(nèi)容發(fā)生改變操作示例
本文實例講述了jQuery實現(xiàn)監(jiān)聽下拉框選中內(nèi)容發(fā)生改變操作。分享給大家供大家參考,具體如下:
jQuery代碼部分:
<script> $(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(); } }); }); </script>
HTML部分:
<form action="${baseUrl}/report/issueStatus.shtml"> <span>Select a project:</span> <select name="selectedProId" id="all"> <c:forEach items="${projectNameId}" var="pi"> <option value="${pi.value}">${pi.key}</option> </c:forEach> <option value="-1" id="allItem">All</option> </select> <span id="timeText">Select a time horizon:</span> <select name="timeHorizon" id="timeSelect"> <option value="Week">Last week</option> <option value="Month">Last month</option> </select> <button type="submit" id="submit">search</button> </form>
更多關于jQuery相關內(nèi)容感興趣的讀者可查看本站專題:《jQuery常見事件用法與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery擴展技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)》
希望本文所述對大家jQuery程序設計有所幫助。
相關文章
jquery+json實現(xiàn)動態(tài)商品內(nèi)容展示的方法
這篇文章主要介紹了jquery+json實現(xiàn)動態(tài)商品內(nèi)容展示的方法,涉及jQuery操作及解析json格式數(shù)據(jù)的相關技巧,需要的朋友可以參考下2016-01-01jQuery插件開發(fā)精品教程讓你的jQuery提升一個臺階
這篇文章主要介紹了jQuery插件開發(fā)精品教程讓你的jQuery提升一個臺階 的相關資料,需要的朋友可以參考下2016-01-01jQuery中通過ajax調(diào)用webservice傳遞數(shù)組參數(shù)的問題實例詳解
本文通過實例給大家詳細介紹jQuery中通過ajax調(diào)用webservice傳遞數(shù)組參數(shù)的相關資料,需要的朋友可以參考下2016-05-05使用Jquery Aajx訪問WCF服務(GET、POST、PUT、DELETE)
使用Jquery Aajx訪問WCF服務(GET、POST、PUT、DELETE),需要的朋友可以參考下2012-03-03