使用 jquery 添加到 html 到类上

Add to html on to class with jquery

本文关键字:html 使用 添加 jquery      更新时间:2023-09-26

所以我想将html添加到具有某个类的每个元素上,但我称之为:

    $(".foldUpSection").find(".header").html($(".foldUpSection").find(".header").html() + 'Some HTML');

插入第一个 .header 中的代码。

我尝试了this但经过思考,我意识到它显然是不确定的。有没有办法在类范围的修改中引用更改的当前实例?

像这样:

$(".foldUpSection").find(".header").html($("self").html() + 'Some HTML');

使用 .append() jquery 函数可以更简单

$( ".foldUpSection .header" ).append('<div class="miniArrow" style="font-weight:bold;float: right;display:block;width:21px; height:21px; margin-right:15px"><img style="height:13px" src="images/rightArrow.png" /></div>');

Js 小提琴示例