【发布时间】:2020-05-27 14:15:51
【问题描述】:
我想使用每个 fn 将元素附加到 id 以 post 开头的所有 div。怎么做才对?
import $ from 'jquery'
export const fn = (): void => {
const $posts = $('[id^="post_id_"]')
if ($posts.length === 0) return
$posts.append('<h1>123</h1>') //works
$posts.each((idx, el) => {
// here i need to do some staff
this.append('<h1>321</h1>') // jQuery.Deferred exception: this.append is not a function TypeError
el.append('<h1>321</h1>') // append as string - not html
})
}
【问题讨论】:
标签: jquery