美文网首页
常见前端JS操作

常见前端JS操作

作者: 夜色001 | 来源:发表于2021-04-26 14:38 被阅读0次

1、获取属性

原生
let id = elem[0].getAttribute("data");
jquery
$('#id').attr('data')

2、修改css

othis.css('background-color','#ff0')

3、移除和添加class

othis.addClass('post-item-active').siblings().removeClass('post-item-active');

相关文章

网友评论

      本文标题:常见前端JS操作

      本文链接:https://www.haomeiwen.com/subject/awwikltx.html