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');
原生
let id = elem[0].getAttribute("data");
jquery
$('#id').attr('data')
othis.css('background-color','#ff0')
othis.addClass('post-item-active').siblings().removeClass('post-item-active');
本文标题:常见前端JS操作
本文链接:https://www.haomeiwen.com/subject/awwikltx.html
网友评论