首页 文章

将内容添加到<div>选择器

提问于
浏览
0

好吧,所以我可能会问一个减少问题,但我似乎无法找到答案 .

如果可能的话,我如何根据当前的类使用jQuery向标记添加内容?

For example adding "CODE" to div like:
<div "CODE" class="class_one"> CONTENT HERE </div>

1 回答

  • 0

    像这样 .

    $('.class_one').each(function() {
        $(this).attr('name', value); // attribute (name="value")
        $(this).data('name', value); // data (data-name="value")
    });
    

相关问题