我有一个这样的jQuery。
$.each($(".fc-daygrid-day "), function (key, val) {
var dateYMD = $(this).attr("data-date");
console.log(this);
$(this).append(`<div class="fc-dailytotal" id='dailytotal-" + dateYMD + "'></div>`);
});
它返回这样的东西。(这是我得到的console.log(this)
)
<td class="fc-daygrid-day fc-day fc-day-thu fc-day-future fc-day-other" data-date="2020-11-05">
<div class="fc-daygrid-day-frame fc-scrollgrid-sync-inner"> <!-- line 2 -->
<div class="fc-daygrid-day-top"><a class="fc-daygrid-day-number">5</a></div>
<div class="fc-daygrid-day-events"></div>
<div class="fc-daygrid-day-bg"></div>
</div>
<div class="fc-dailytotal" id="dailytotal-" + dateYMD + "">0</div> <!-- line 1 -->
</td>
我想在第 2 行 div 标签内附加第 1 行?我想要的最终结果如下。谢谢你。(我是 JQuery 的新手)
<td class="fc-daygrid-day fc-day fc-day-thu fc-day-future fc-day-other" data-date="2020-11-05">
<div class="fc-daygrid-day-frame fc-scrollgrid-sync-inner"> <!-- line 2 -->
<div class="fc-daygrid-day-top"><a class="fc-daygrid-day-number">5</a></div>
<div class="fc-dailytotal" id="dailytotal-" + dateYMD + "">0</div> <!-- line 1 -->
<div class="fc-daygrid-day-events"></div>
<div class="fc-daygrid-day-bg"></div>
</div>
</td>