js常用函数

1.attr函数  设置属性值 根据参数不同 作用不同

 $("buttoon").click(function(){

    $("img").attr("width","180")  

  })

  效果 点击按钮 所选属性img 的width属性会变成所设置的大小180

  1.返回被选到属性值  $(selector).attr(attribute)

  2.设置被选元素的属性和值 $(selector).attr(attribute,value) 可以说多对 $(selector).attr({attribute:value,attribute:value...})

    $(selector).attr(attribute,function(index,oldvalue))

  

2.stringify  json.stringify(); 将 javascript值转化为json 字符串   如果指定了replacer是一个函数,则可以替换值,或者如果指定了replacer是一个数组,可选的仅包括指定的属性。、

 

  --js样式 设计

 

<th data-options="field:'表中字段',align:'center',width:'10%'" formatter="format.accessformat">表头</th>

var format = {
  accessformat:function accessformat(val, row){
    if (val == "0") {
      return "<div class='ui-miss-custorm'><img src='../images/customer1.png'>AAA</div>";
    } else {
      return "<div class='ui-miss-custorm'><img src='../images/customer2.png'>BBB</div>";
    }
  },

}

 

 

 

参考地址: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

 

 

持续更新..............

posted @ 2019-02-21 10:21  G_Lybbh  阅读(196)  评论(0编辑  收藏  举报