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

    推荐阅读