I want to use each fn to append elements to all divs where id starts with post. How to do it right?
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
})
}