Jquery 根据value值设置下拉列表(select)默认选中项
方法一:
$("#selIndustyType option[value='1']").attr("selected", "selected");
方法二:
<script type="text/javascript">
function change(objID, newValue) {
var obj = $("#" + objID);
if (!obj) {
alert("对象为空,执行返回!");
return;
} var options = obj.find("option");
options.each(function (i) {
if ($(this).text() === newValue) {
$(this).attr("selected", true); -- 也可用 obj.get(0).selectedIndex = i; 替代
}
});
}
</script>
Jquery 根据value值设置下拉列表(select)默认选中项的更多相关文章
- 使用val()方法设置表单中的默认选中项
有时候我们展示给用户的表单中的checkbox,radio,selec等标签的一些项是默认选中的.比方:当用户改动文章的时候,假设相应的栏目为下拉框的话,那么它的默认选中值应该是原来的栏目位置. 能够 ...
- angularjs中设置select的选中项
最近用angularjs比较多,里面有很多自己的方法,都不咋会用,这篇只是个笔记,防止自己忘记 <select style="width:100%" ng-model=&qu ...
- layui动态修改select的选中项
layui动态修改select的选中项:(在layUI下给select设置默认选项) 例: $("select[name='result']").val(11); //重新渲染表单 ...
- angularjs ng-select ng-options 默认选中项.
<!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="utf- ...
- struts2设置<s:select>默认选中项的方法
struts2的select标签中,常用的有以下几个属性:(1)struts2中的select 标签中,必须设置的属性只有一个,即是list.(2)select标签的list中必须有值,不然会报错.如 ...
- easyui-combobox 中多选的默认值设置、获取多选值及JS包含字符串、删除字符串
1.项目中使用到combobox的多选值及相关操作,不多说,直接上代码: <input id="education" name="education" c ...
- 根据值设置select的选中项
$('.selector').attr("checked", true); <s:iterator value="jobSelect" id=" ...
- jquery 根据数据库值设置radio的选中
jsp代码: <label>性 别</label> <input type="radio" value="1" name=&quo ...
- Android RadioGroup设置默认选中项
今天有人问.Android 里面 RadioGroup里面有两个RadioButton怎么设置默认值? 第一个RadioButton设置 android:checked="true" ...
随机推荐
- Codeforces Round #340 (Div. 2) E. XOR and Favorite Number 莫队算法
E. XOR and Favorite Number 题目连接: http://www.codeforces.com/contest/617/problem/E Descriptionww.co Bo ...
- 泛型Dictionary的用法详解
泛型最常见的用途是泛型集合,命名空间System.Collections.Generic 中包含了一些基于泛型的集合类,使用泛型集合类可以提供更高的类型安全性,还有更高的性能,避免了非泛型集合的重复的 ...
- 说说C#静态变量的诡异与恶心
发现一段很诡异的C#代码,见识了静态构造函数这种奇怪的东西: using System; namespace StaticTest { class A { public static int X; s ...
- ASP.NET方面的一些经典文章收集
1. 在ASP.NET中执行URL重写 文章地址:https://msdn.microsoft.com/zh-cn/library/ms972974.aspx 2. 在ASP.NET中如何实现和利用U ...
- GPS获取Location 获取所在地点的经纬度
利用手机获取所在地点的经纬度: Location 在Android 开发中还是经常用到的,比如 通过经纬度获取天气,根据Location 获取所在地区详细Address (比如Google Map 开 ...
- [Angular 2 Router] Configure Your First Angular 2 Route
Using the Angular 2 router requires defining routes, passing them in to the RouterModule.forRoot and ...
- MySQL 调优基础:Linux内存管理 Linux文件系统 Linux 磁盘IO Linux网络
http://www.cnblogs.com/digdeep/category/739915.html
- 检测MYSQL不同步发邮件通知的脚本
脚本代码如下:#!/bin/bash ...
- linux man使用方法 和centos安装中文man包 --转
http://blog.chinaunix.net/uid-25100840-id-302308.html 这两天学习<linux设备驱动程序开发详解>中的异步通知,其中有一个fcntl( ...
- iOS10 资料汇总:值得回看的 10 篇 iOS 热文
本文精选了 iOS大全 9月份的10篇热门文章.其中有软件推荐.技术分享及iOS10.Xcode8新特性等. 注:以下文章,点击标题即可阅读 <兼容iOS 10 资料整理笔记> 本文整理i ...