Select2 如何设置值?
2015-10-08 17:08
357 查看
I know if i have a select2 and i want to set one of the options, i can do run this code.
Lets say i want to get the text of the option
but if i want to set it based on the text not the value, how do i do it?
I tried doing
but it didnt work.
How can i do this programatically in jquery or javascript.
Any help is appreciated
$(document).ready(function(){ $('#btn').change(function(){ $('#select').val(4).trigger("change") }); });
Lets say i want to get the text of the option
<option value=4>California</option>
but if i want to set it based on the text not the value, how do i do it?
I tried doing
$("#select").select2(data.text(), "California");
but it didnt work.
How can i do this programatically in jquery or javascript.
Any help is appreciated
相关文章推荐
- ab测试网站吞吐率介绍
- Java 集合系列14之 Map总结(HashMap, Hashtable, TreeMap, WeakHashMap等使用场景)
- 我的小树林
- 什么是软件生命周期模型,比较几个模型的优缺点
- ubuntu14下安装MySQLdb报错的解决办法
- java自动类型提升
- That Diesel powered running watches north america doesn't need shift and legal requirements within any specific time
- Windows下搭建MySQL Master Slave
- html a标签中的文字怎么居中对齐
- Android 插值属性动画Property Animation
- javascript 获取链接url我一些位置的内容
- Linux学习之路-DNS原理-BIND配置详解
- linux cron
- Java 集合系列13之 WeakHashMap详细介绍(源码解析)和使用示例
- 论文提要“Learning Deepface Representation”
- django test数据库乱码
- 新来的第一天,小小的code,准备飞翔.
- Activity生命周期
- 【CS】尺度不变特征变换匹配算法SIFT
- touch事件