其他分享
首页 > 其他分享> > 页面j开发---规范-个人总结

页面j开发---规范-个人总结

作者:互联网

一、本页面元素取值

1、值

使用jQuery

$('#select1').val();

 

 

2、html

$('#select1').html();

 

3、selected

1. $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发
 
2. var checkText=$("#select_id").find("option:selected").text(); //获取Select选择的
 
3. var checkValue=$("#select_id").val(); //获取Select选择的Value
 
4. var checkIndex=$("#select_id ").get(0).selectedIndex; //获取Select选择的索引值
 
5. var maxIndex=$("#select_id option:last").attr("index"); //获取Select最大的索引值

 

 

4、checked

 

 

 

二、本页面元素赋值

1、值

$(".selector").val("pxx");//选中option值为pxx的项
$(".selector").find("option[text='pxx']").attr("selected",true);//设置text为pxx的项选中

 

 

 

 

2、html

 

3、selected/checked

三、获取sessionStorage中的数据到本页面

 

四、获取Session/request中的的数据到本页面

 

 五、添加元素

 

标签:总结,pxx,selected,---,select,id,Select,页面
来源: https://www.cnblogs.com/hehehenhen/p/15528566.html