获得:
this.html()
is not a function?
$('a[href*="section"]').click(function() {
var texthtml = this.html();
$(document).find("div.SectionExpandable__title:contains("+texthtml+")").click();
});
如何从 a
标签中获取 html,以便将其传递给代码的下一部分?
最佳答案
当使用 this
时,您可以在其上调用 DOM 方法,但不能调用 jQuery 方法。使用 $(this)
时,您可以在其上调用 jQuery 方法,但不能调用 DOM 方法。
和html()
是jQuery方法,所以:
改变:
this.html();
收件人:
$(this).html();
关于javascript - 使用 jquery 选择 'a' 标记中的 html 但获取 html 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39425023/