1前端琐碎

1.<a>链接获取属性

当JS拼接脚本需要获取a连接的属性

href="javascript:xxx(this);"和onclick="javascript:xxx(this);"

前者的this根本拿不到触发事件的A标签,而后者可以拿到

推荐写成

"<a href='javascript:openItems(" + row.itemid
+ ")'>查看</a> &nbsp" + "<a id='"+ row.itemid+"' name='"+row.itemname+"' href='javascript:void(0);' onclick='javascript:editItems(this)'>编辑</a>";

 

posted on 2018-03-28 11:48  freeo  阅读(200)  评论(0编辑  收藏  举报