<input class="SL" value="0" sl="123" >

上面是一个input控件,class为SL,值为0,自定义属性sl为123,id为A

<input class="SL" value="1" sl="456" >

上面是一个input控件,class为SL,值为1,自定义属性sl为456,id为B

JS获取上面两个控件的属性

var Val=""; //获取值

var sl="";//自定义的值

var ID="";//ID的值

$(".SL").each(function(){
Val  +=$(this).val()+','; //(获取两个控件的val值并且用逗号拼接)

  sl  +=$(this).attr("sl")+ ',';//(获取两个控件的自定义值并且用逗号拼接)

  ID+=$(this).attr("id")+ ',';//(获取两个控件的ID并且用逗号拼接)
});

 

相关文章:

  • 2021-11-22
  • 2022-12-23
  • 2021-09-15
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2021-07-07
相关资源
相似解决方案