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的操作的更多相关文章

  1. jquery select取值,赋值操作

    select">jquery select取值,赋值操作 一.获取Select 获取select 选中的 text : $("#ddlRegType").find( ...

  2. JQuery select控件的相关操作

    JQuery获取和设置Select选项方法汇总如下: 获取select 先看看下面代码: $("#select_id").change(function(){//code...}) ...

  3. jQuery select的操作代码

    jQuery對select的操作的实际应用代码. //改變時的事件  复制代码代码如下: $("#testSelect").change(function(){ //事件發生  j ...

  4. jQuery设置radio、select、checkbox只读属性后,如何在后台得到数据

    1 设置表单的readonly属性 对于radio.select.checkbox来说,readonly属性对这三个标签不起什么作用. 2 设置表单的disabled属性 以radio为例说明. 代码 ...

  5. jQuery select的操作实现代码

          //改变时的事件  $("#testSelect").change(function(){ //事件发生生 jQuery('option:selected', this ...

  6. jQuery(6)——jQuery对表单、表格的操作及更多应用

    jQuery对表单.表格的操作及更多应用 [表单应用] 一个表单有表单标签.表单域及表单按钮三个基本部分. 单行文本框应用:获取和失去焦点改变样式. 也可以用CSS中的伪类选择符来实现,但是IE6并不 ...

  7. html select控件的jq操作

    html select控件的jq操作 1.判断select选项中 是否存在Value="paraValue"的Item $("#selectid option[@valu ...

  8. 使用jQuery获取radio/checkbox组的值的代码收集

    <!-- $("document").ready(function(){ $("#btn1").click(function(){ $("[na ...

  9. 基础问题:设置radio、select、checkbox 的readonly 属性

    编辑记录的时候,有时候需要禁止用户修改某些项目,常用的方法有以下两种: 1>设置表单的readonly属性问题:但是readonly属性对radio.select.checkbox这三个表单不起 ...

随机推荐

  1. ubuntu 13.10 amd64安装ia32-libs

    很多软件只有32位的,有的依赖32位库还挺严重的:从ubuntu 13.10已经废弃了ia32-libs,但可以使用多架构,安装软件或包apt-get install program:i386.有的还 ...

  2. mybatis存入数据库后没有时分秒时间不全只有年月日

    对于Ibatis操作Date/Time/DateTime,总结如下: 将pojo的属性类型设置为java.sql.Date(或java.sql.Time, java.sql.Timestamp),此时 ...

  3. MVC自带的校验

    一.添加控制器Home和Model数据 public class UserInfo { public int Id { get; set; } [Display(Name="用户名" ...

  4. LINUX_source

    Be careful! ./ and source are not quite the same. ./script runs the script as an executable file, la ...

  5. centos7下yum安装mysql

    CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载   # wget http://dev.mysql.com/get/mysql-communit ...

  6. 如何解决adb devices 端口被占用的问题zz

    在win xp ,win 7 上使用adb时, 越来越多的人出现了 adb devices 命令长时间无响应.adb start-server 失败.eclipse adt初始化时卡在dbms-ini ...

  7. Android VLC播放器二次开发1——程序结构分析

    最近因为一个新项目需要一个多媒体播放器,所以需要做个视频.音频.图片方面的播放器.也查阅了不少这方面的资料,如果要从头做一个播放器工作量太大了,而且难度也很大.所以最后选择了VLC作为基础,进行二次开 ...

  8. php session跨页面传递 session值丢失问题

    .session_start();应该尽量放置到页面的顶部: .如果php.ini里面没有配置 session Autostart的话,每次会话之前,都得手动开启session:session_sta ...

  9. LightOJ 1079 Just another Robbery 概率背包

    Description As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (h ...

  10. AutoCompleteTextView自动填充文本

    布局: <AutoCompleteTextView android:id="@+id/auto" android:layout_width="match_paren ...