jq操作select集合
最近一段时间发现,老是要跟select,option相关的东西打交道,而且有的时候还会搞错,于是,抽了一点时间整理了一份使用jq库来操作select的一些事件及方法,供大家参考。
html代码:
1
2
3
4
5
6
7
8
9 |
<</code> <</code> <</code> <</code> <</code> <</code> <</code> <</code> </</code> |
获取Select:
获取select选中的text
获取select选中的val
获取select选中的索引
设置Select:
设置select选中的text
设置select选中的value
设置select选中的索引
index;//index为索引值
设置select option项
/option>"); //添加一项option
/option>"); //在前面插入一项option
option[index=0]").remove();//删除索引值为0的Option
//删除值为3的Option
清空 Select
版权声明:本文为博主原创文章,未经博主允许不得转载。
jq操作select集合的更多相关文章
- jq 操作select
添加option $("#ID option").each(function(){if($(this).val()==111){$(this).remove();}}); 移除op ...
- JQ操作select项
jQuery获取Select元素,并选择的Text和Value: 1. $("#select_id").change(function(){//code...}); //为Se ...
- jquery操作select的各种方法
在工作中,有时候会遇到给select组件添加一些事件,前两天发表了一篇文章,<用jquery给select加选中事件>大致阐述了简单的jq操作select的方法,但是为了详细的介绍一下se ...
- JS中Float类型加减乘除 修复 JQ 操作 radio、checkbox 、select LINQ to SQL:Where、Select/Distinct LINQ to SQL Count/Sum/Min/Max/Avg Join
JS中Float类型加减乘除 修复 MXS&Vincene ─╄OvЁ &0000027─╄OvЁ MXS&Vincene MXS&Vincene ─╄Ov ...
- html select控件的jq操作
html select控件的jq操作 1.判断select选项中 是否存在Value="paraValue"的Item $("#selectid option[@valu ...
- JAVASE02-Unit03: 日期操作 、 集合框架
Unit03: 日期操作 . 集合框架 java.util.Date package day03; import java.util.Date; /** * java.util.Date * Date ...
- Jquery操作select,左右移动,双击移动 取到所有option的值
$(function () { function MoveItem(fromId, toId) { $("#" + fromId + " option:selected& ...
- jquery 操作select 资料
每一次操作select的时候,总是要出来翻一下资料,不如自己总结一下,以后就翻这里了. 比如<select class="selector"></select&g ...
- jquery操作select(增加,删除,清空)
jQuery获取Select选择的Text和Value: $("#select_id").change(function(){//code...}); //为Select添加事件, ...
随机推荐
- Mac 常用属性
如果需要让隐藏的文件可见. 具体做法就是打开一个Terminal终端窗口,输入以下命令: 对于OS X Mavericks 10.9: defaults write com.apple.finder ...
- python classmethod方法 和 staticmethod
classmethod() 是一个类方法,用来装饰对应的函数.被classmethod 装饰之后就无需实例化,也不需要在函数中传self,但是被装饰的函数第一个参数需要是cls来表示自身类.可以用来调 ...
- java基本类型和包装类的区别(转)
int 是基本类型,直接存数值 Integer是类,产生对象时用一个引用指向这个对象 Java把内存划分成两种:一种是栈内存,另一种是堆内存 在函数中定义的一些基本类型的变量和对象的引用变量都是在函数 ...
- git查看某一次commit里面的内容,即本次commit相对于原来的版本进行了哪些修改
1 知道commit id的话 git show commit-id 2 想要查看某次commit的某个文件进行了哪些修改 git show commit-id filename
- cocos2d-js v3.1的坑
前几天因为要用到cc.pool,所以就换了v3.1版本,结果连生成apk的出错(cocos code ide), log显示为:error: relocation overflow in R_ARM_ ...
- 利用framebuffer,命令行显示图片
上代码 import fcntl import struct import mmap import contextlib import os import time import numpy as n ...
- Java for LeetCode 096 Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...
- turbolink 造成 link_to异常
link_to 点击之后不刷新不加载文件 send_file 只能在浏览器中打开,而不能下载 解决方法:注释gem turbolink,application.js 中移除turbolink
- Vue-router进阶、单页面应用(SPA)带来的问题
一 . vue-router 进阶 回顾学过的vue-router,并参考官方文档学习嵌套路由等路由相关知识. 二 . 单页面应用(SPA)带来的问题 1 . 虽然单页面应用有优点 , 但是,如果后端 ...
- Redis 的持久化与过期键
简介 Redis 是使用非常广泛的 Key-Value 内存数据库.因为数据都存放在内存中,所以存取速度非常快.不过,很多情况下我们需要将 Redis 中的数据保存到硬盘中以便做备份.Redis 提供 ...