-
2022-02-17 13:58:10
1.当Jquery是1.9以下版本:
$('#selector').live('change',function(){ /*执行的代码*/ })
2.当Jquery版本大于1.9
$('body').on('change','#selector',function(){ /*执行的代码*/ })
3.简单版,推荐使用编号2的代码
$('select.form-control-ele').change(() => { let super_id = $('select.form-control-ele').val(); console.log(super_id); });
更多相关内容 -
select获取下拉框的值 下拉框默认选中方法
2020-12-29 03:20:511、通过id获取下拉框的value和文本值 例如: <select class=form-control id=numbers> 数字1 数字2 </select> $(#numbers option:selected).val(); 获取到下拉框被选中的optionde value值:2; $(#... -
jsp获取下拉框选中值并传入action
2020-04-06 15:51:49jsp获取下拉框选中值并传入action 运用el表达式和jstl 及javascript <form action="${pageContext.request.contextPath }/user/userlist.html"> <span>用户名称:</span> <input name=...jsp获取下拉框选中值并传入action
运用el表达式和jstl 及javascript
<form action="${pageContext.request.contextPath }/user/userlist.html"> <span>用户名称:</span> <input name="userCode" type="text" value="${user.userCode}"> <span>用户角色:</span> <select id="testSelect" onchange="changeSelect()"> <%-- 添加一个所有的下拉框选项 值为0--%> <option value="0">所有</option> <c:forEach var="role" items="${roles }"> <c:if test="${user.userRole == role.id}"> <option value="${role.id}" selected>${role.roleName}</option> </c:if> <c:if test="${user.userRole != role.id}"> <option value="${role.id}">${role.roleName}</option> </c:if> </c:forEach> </select> <%-- 传入action的userRole 隐藏input--%> <input type="hidden" id="userRole" name="userRole" value="" /> <input type="hidden" name="pageIndex" value="1"/> <input value="查 询" type="submit" id="searchbutton"> <a href="${pageContext.request.contextPath }/jsp/useradd.jsp">添加用户</a> </form>
关于引入的js文件
<script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/userlist.js"></script>
js文件中具体操作(针对下拉框的代码复制)
//下拉框改变 function changeSelect(){ if($('#testSelect option:selected') .val()=="0"){ $('#userRole').val(""); }else{ $('#userRole').val($('#testSelect option:selected') .val()); } }
完啦 随写随记
-
jquery及原生js获取select下拉框选中的值示例
2020-12-11 16:57:45现在有一id=test的下拉框,怎么拿到选中的那个值呢? 分别使用javascript原生的方法和jquery方法 代码如下: <select id=”test” name=””> ”1″>text1</option> ”2″>text2</option> </select> 一:... -
python爬虫获取下拉框选中值
2020-12-07 14:35:23item['xb'] = response.xpath('//*[@id="Sex"]/option[contains(@selected,"selected")]/@value').extract_first()item['xb'] = response.xpath('//*[@id="Sex"]/option[contains(@selected,"selected")]/@value').extract_first()
-
jQuery实现select下拉框获取当前选中文本、值、索引
2020-10-19 21:33:24本篇文章主要介绍了jQuery实现select下拉框获取当前选中文本、值、索引以及添加/删除Select的Option项的相关知识,具有很好的参考价值。下面跟着小编一起来看下吧 -
js获取下拉框选中的值
2021-06-07 10:38:13for(var i = 0;i ;... } } function into(){ var value =document.getElementById("values");//1:获取select对象 var index=value.selectedIndex;...//3:获取选中项的value console.log(val);//比如选的优 ,val就为优function ViewList(){ html += '<div>评价</div>' ; html += '<div>提交</div>' ; for(var i = 0;i < data.length ; i++){ html += '<div>' + '<select id="values">' + '<option value="优">优</option>' + '<option value="良">良</option>' + '<option value="中">中</option>' + '<option value="差">差</option>' + '</select>' + '</div>'; html += '<div>' + '<input type="button" value="提交评价" οnclick="into()" >' + '</div>'; } } function into(){ var value =document.getElementById("values");//1:获取select对象 var index=value.selectedIndex;//2:取到选中项的索引 var val=value.options[index].value;//3:获取选中项的value console.log(val);//比如选的优 ,val就为优
-
vue 获取下拉框选中的值
2022-05-17 19:11:49<template> <div class=""> <select @change="getEventType($event)"> <option v-for="option in list" :key="option.value" :id="option.value" :name="option.name" ... -
记录 Vue 获取下拉框选中值的整个对象的数据
2022-06-13 19:17:41获取下拉框选中值的整个对象的数据 -
原生js获取下拉框选中值的下标
2020-10-14 17:53:36//获取选中值的下标 function getselectscheckitemindex (idStr) { var o = document.getElementById(idStr).options for (var i = 0; i < o.length; i++) { if (o[i].selected == true) return i } } /... -
在Vue 中获取下拉框的文本及选项值操作
2021-01-19 14:41:22方法1: <!-- element表单组件 --> :model=ruleForm label-position right ref=ruleForm u6807记的 status-icon size=small inline :rules rules label-width=150px ...el-input v-model.number=rul -
angularjs 动态从后台获取下拉框的值方法
2020-10-18 05:44:02今天小编就为大家分享一篇angularjs 动态从后台获取下拉框的值方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧 -
JavaScript案例 全选 获取下拉框选中的值
2022-03-26 14:07:45添加音乐 哪里都是你 关于你 偏爱 Love Story(Taylor's Version) 晚风 蜜蜂 这首歌没唱直接听 获取下拉框选中的值 青铜班 白银班 黄金班 铂金班 钻石班 页面加载获得焦点 用户名:... -
Layui获取Select下拉框选中值
2021-11-01 10:32:22定义下拉框: <div class="layui-inline"> <label class="layui-form-label " style="width:120px">督学主题:</label> <div class="layui-input-inline"> <select id="Threme -
C# 使用Winform 获取下拉框 选中的值
2021-03-28 18:59:55我就废话不多说了,大家还是直接看代码吧~ string PrintName = cmbPrinter.SelectedIndex.... 获取SelectionChanged后选中的值 combobox.SelectedItem; 以上为个人经验,希望能给大家一个参考,也希望大家多多支持 -
html获取下拉框的值和文本
2022-04-21 17:55:15其中info是select的id,后面的option:checked表示选中的选项 var id = $("#info option:checked").val(); var name = $("#info option:checked").text(); 参考 (32条消息) JQuery中,select标签使用val()方法... -
jQuery 获取和设置select下拉框的值实现代码
2020-12-01 22:16:24获取select 选中的 text : $(“#ddlRegType”).find(“option:selected”).text(); 获取select选中的 value: $(“#ddlRegType “).val(); 获取select选中的索引: $(“#ddlRegType “).get(0).selectedIndex; 设置... -
获取下拉框选中的值和下标项
2021-03-05 17:17:12var options=$("#selectKeyId option:selected");//获取当前选择项. let delarers_key = options.val();//获取当前选择项的值. let delarers_keyText = $('#selectValId').val();//获取搜索输入框的值 -
获取下拉框中选中的值
2021-06-21 19:34:43原生js和jquery定位方式 # 1、原生js方式定位 var myselect=document.... //获取选中的项 或 var options=$("#id"); alert(options.val()); //拿到选中项的值 alert(options.text()); //拿到选中项的文本 -
获取下拉框选中的索引值
2022-06-11 10:59:59selectedIndex 属性可设置或返回下拉列表中被选选项的索引号。 -
jquery怎么获取下拉框的值
2021-06-12 14:08:32怎样用jquery得到select里面选中的值456var a = $('#select').val(); // 结果为 123var b = $('#select option:selected').val(); // 结果为 123var d = $('#select option:selected').attr('value'); // 结果为 123... -
jQuery操作选中select下拉框的值代码实例
2020-11-21 07:45:59这篇文章主要介绍了jQuery操作选中select下拉框的值代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 js和jQuery联合操作dom真的很好用,如果不是专业... -
JQuery获取下拉框所有选中的目标值
2020-07-27 14:29:34<div class="layui-input-inline"> <select class="layui-select" name="shop_id" id="shop_id" lay-search> {foreach [''=>'- 选择店铺 -','0'=>'否','1'=>'是'] as $k=>... -
JQuery获取select下拉框的值
2019-03-11 17:00:55获取第一个option的值 $('#test option:first').val(); 最后一个option的值 $('#test option:last').val(); 获取选中的值 $('#test').val(); $('#test option:selected').val(); -
jQuery Easy UI中根据第一个下拉框选中的值设置第二个下拉框是否可以编辑
2020-10-21 00:48:14主要介绍了jQuery Easy UI中根据第一个下拉框选中的值设置第二个下拉框是否可以编辑的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下 -
获取下拉框选中的文本内容
2020-08-24 20:00:32//获取下拉框选中的项 var option = $("#sTrainno option:selected"); //获取下拉的name值 var text = option.text(); alert(text); //将下拉框的name值赋值给文本框 var val = $("#trainNumber").val... -
.net WebFrom项目绑定和获取下拉框的值
2021-03-17 11:44:32自己做个笔记,省的忘记代码了还要到处找 前台aspx界面 ...下拉框绑定数据 string sql = "select * from BasCodeTest (nolock) where Type='WGSite'"; DataTable dt = oDal.GetDataTable(sql);//这里是数据
收藏数
23,617
精华内容
9,446