Jquery - Select 和 Checkbox 、Textarea的操作
Checkbox
//判断是否选中
if ($(this).is(':checked'))
{
alert("它处于选中状态");
}
else
{
alert("它不处于选中状态");
} if(document.getElementById("checkboxID").checked)
{
alert("它处于选中状态");
} //判断是否选中通常是使用prop而不是attr
if($("IsWeek").prop("checked") == true) _IsWeek = 1;
选中
$("input:checkbox[name='SNID_PK']").click();
取消选中
$("#day").removeAttr("checked");
获取状态为【已选中】的checkbox的数量
var num = $("input:checkbox[name='checkbox']:checked").size();
Select
匹配所有选中的option元素
$("select option:selected")
选择事件 change 事件
$('select').change(function (e) {
var _attr_id = $(this).find("option:selected").attr('attr-id');
console.log(_attr_id);
})
根据text值设置为选中
$(".selector").find("option[text='pxx']").prop("selected",true);
$(".selector").find("option:contains('pxx')").prop("selected",true);
// $(e).find("option[value="+ value +"]")
获取当前选中项的value
$(".selector").val();
获取当前选中项的text
$(".selector").find("option:selected").text();
纯js方式获取text
var index = document.getElementById('select').selectedIndex;
var text = document.getElementById('select').options[index].text;
console.log(20180726092552, index, text)
清空下拉列表
$("select#select1").empty();
Textarea换行符替换
var str = $("#Cy-Tp-ShopCode").val();
str = str.replace(/\n/g, ","); //用g开启贪婪模式匹配替换所有
Jquery - Select 和 Checkbox 、Textarea的操作的更多相关文章
- jquery select取值,赋值操作
select">jquery select取值,赋值操作 一.获取Select 获取select 选中的 text : $("#ddlRegType").find( ...
- JQuery select控件的相关操作
JQuery获取和设置Select选项方法汇总如下: 获取select 先看看下面代码: $("#select_id").change(function(){//code...}) ...
- jQuery select的操作代码
jQuery對select的操作的实际应用代码. //改變時的事件 复制代码代码如下: $("#testSelect").change(function(){ //事件發生 j ...
- jQuery设置radio、select、checkbox只读属性后,如何在后台得到数据
1 设置表单的readonly属性 对于radio.select.checkbox来说,readonly属性对这三个标签不起什么作用. 2 设置表单的disabled属性 以radio为例说明. 代码 ...
- jQuery select的操作实现代码
//改变时的事件 $("#testSelect").change(function(){ //事件发生生 jQuery('option:selected', this ...
- jQuery(6)——jQuery对表单、表格的操作及更多应用
jQuery对表单.表格的操作及更多应用 [表单应用] 一个表单有表单标签.表单域及表单按钮三个基本部分. 单行文本框应用:获取和失去焦点改变样式. 也可以用CSS中的伪类选择符来实现,但是IE6并不 ...
- html select控件的jq操作
html select控件的jq操作 1.判断select选项中 是否存在Value="paraValue"的Item $("#selectid option[@valu ...
- 使用jQuery获取radio/checkbox组的值的代码收集
<!-- $("document").ready(function(){ $("#btn1").click(function(){ $("[na ...
- 基础问题:设置radio、select、checkbox 的readonly 属性
编辑记录的时候,有时候需要禁止用户修改某些项目,常用的方法有以下两种: 1>设置表单的readonly属性问题:但是readonly属性对radio.select.checkbox这三个表单不起 ...
随机推荐
- CI框架初探
2014年7月3日 17:39:35 简易版: index.php->codeIgniter.php->找到控制器类文件并include->创建实例->执行成员函数 详细版本: ...
- Ubuntu 14.04的vim编辑器配置Python开发环境
#1 $ sudo apt-get install exuberant-ctags vim-scripts $ vim-addons install taglist #2 到:http://www.v ...
- 【python】lxml查找属性为指定值的节点
假设有如下xml在/home/abc.xml位置 <A> <B id=" name="apple"/> <B id=" name= ...
- UVALive 7270 Osu! Master (阅读理解题)
题目:传送门. 题意:阅读理解题,是一个osu的游戏,问得分.把题目翻译过来就是如果出现S或者BC后面跟的是1,ans就加1. #include <iostream> #include & ...
- HDU 3835 R(N)
R(N) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- Java性能优化权威指南-读书笔记(五)-JVM性能调优-吞吐量
吞吐量是指,应用程序的TPS: 每秒多少次事务,QPS: 每秒多少次查询等性能指标. 吞吐量调优就是减少垃圾收集器消耗的CPU周期数,从而将更多的CPU周期用于执行应用程序. CMS吞吐调优 CMS包 ...
- SQL 删除存在于A表但是不存在B表中的记录
目的是是的A表和B表某一个列集合相等 delete from A where tagetColumn not in ( select targetColumn from B)
- Ubuntu使用tcpdump工具
Ubuntu默认是安装好了tcpdump工具的,如果没有安装的话使用sudo apt-get install tcpdump即可安装. (如果遇到tcpdump: no suitable devi ...
- [转]Java 内部类笔记
内部类是指在一个外部类的内部再定义一个类.内部类作为外部类的一个成员,并且依附于外部类而存在的.内部类可为静态,可用protected和private修饰(而外部类只能使用public和缺省的包访问权 ...
- ***CI新增记录成功后的返回值判断,是用isset还是empty
Q: 新增记录插入成功后,加了一个return $this->db->insert_id(); $digg_id = $this->m_feed_digg->create(js ...