常用js、jquery 语句(句型)

1、动态更改设置属性(class  style 都是属性)

$("#sendPhoneNum").attr("class", "n_input3");  

$("#top_notice").attr("style", "display:block;");  

2、通过css()设置样式

$("#sendPhoneNum").css("display", "none");  

3、使用ajax

$.ajax({
  type : "post",
  url : "${ctx}/role/testcheck.do",
  dataType : "json",
  data : json,
  contentType : 'application/json;charset=utf-8',
  success : function(result) {

  }

  });

4、绑定事件

$("#onProvince").on("change", function() {});     //通用事件绑定

 

$table.on("change",":checkbox",function() { }).on("click",".td-checkbox",function(event) {

//点击单元格即点击复选框
!$(event.target).is(":checkbox")
&& $(":checkbox", this).trigger("click");
});

//在表格中可以使用如上面的形式给特定子项绑定事件

5、获取值

var item = _table.row($(this).closest('tr')).data();
$(this).closest('tr').addClass("active").siblings()
.removeClass("active");

//获取表格里边的值

原文地址:https://www.cnblogs.com/keefer/p/6427513.html