jquery小技巧

来源:互联网 发布:人工智能的伦理困境 编辑:程序博客网 时间:2024/05/22 04:31

1、根据input的name属性值取值

$("input[name='mobile']").val() 

2、根据标签的id属性取值

$("#mobile_reg_form").html() 

3、取出form 中的input

var a=$("form input");   

4、得到多个值

$("input[name='mobile']")[0].value

$("input[name='mobile']").get(1).value  

6、得到某个样式

$(".mobile_reg_form").html() 

7、添加样式

$("#id").addClass("style");

8、 删除样式

$("#id").removeClass("style");  

9、转为整数

var productnum=parseInt(jqinput.val());

10、获取值

theli.find('input').val();

11、遍历,

 var expid=new Array();

$("[name='desideBuy']").each(function(){ //遍历name='desideBuy'的标签

  if(!$(this).attr("checked")) // 获取当前对象属性为checked 的值
    {
       var pid = "li"+$(this).attr("goodsid"); 
        expid.push(pid);  //向数组中加入值
         }
});

12、创建对象,并赋值

  var actionobj=new Object();
      actionobj.id=removeid;

13、声明静态数据

  var arraycycle=['onetotal','productprice','sumall'];

14、查找input属性

var theli=$(this).parent().parent().parent();
var jqinput=theli.find('input');


           



0 0
原创粉丝点击