jquery|jquery selector 使用方法
jquery selector 使用方法
1 设置value为pxx的项选中
$(".selector").val("pxx");
2 设置text为pxx的项选中
$(".selector").find("option[text='pxx']").attr("selected",true);
3 获取当前选中项的value
$(".selector").val();
4 获取当前选中项的text
$(".selector").find("option:selected").text();
select的级联,即第二个select的值随着第一个select选中的值变化。这在jquery中是非常简单的。$(".selector1").change(function(){
// 先清空第二个
$(".selector2").empty();
// 实际的应用中,这里的option一般都是用循环生成多个了
var option = $("
posted on 2015-12-10 12:07 北京涛子 阅读( ...) 评论( ...) 编辑 收藏 【jquery|jquery selector 使用方法】转载于:https://www.cnblogs.com/liujitao79/p/5035555.html
推荐阅读
- 事件代理
- jQuery插件
- 迅捷流程图制作软件的使用方法!
- 7、前端--jQuery简介、基本选择器、基本筛选器、属性选择器、表单选择器、筛选器方法、节点操作、绑定事件
- Spring|Spring Boot之ImportSelector
- performSelectorOnMainThread:withObject:waitUntilDone:参数设置为NO或YES的区别
- python|python random使用方法
- 进阶任务十四
- jQuery之trigger()方法
- jQuery中的DOM操作