Getting:
this.html()
is not a function?
$('a[href*="section"]').click(function() {
var texthtml = this.html();
$(document).find("div.SectionExpandable__title:contains("+texthtml+")").click();
});
How do I get the html from an a
tag so I can pass it to the next part of the code?
When using this
, you can call DOM methods on it, but not jQuery methods. When using $(this)
, you can call jQuery methods on it, but not DOM methods.
and html()
is jQuery method, so :
Change :
this.html();
To :
$(this).html();
you need to reference the jquery element via $(this)
$('a[href*="section"]').click(function() {
var texthtml = $(this).html();
$(document).find("div.SectionExpandable__title:contains("+texthtml+")").click();
});
$('a[href*="section"]').click(function() {
var texthtml = jQuery(this).html();
$(document).find("div.SectionExpandable__title:contains("+texthtml +")").click();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.