I need to return a string that is nested within a DOM element. The string looks like a value that is stored to a key or attribute called "selector"
I've been using the console to try to get down to that string.
My HTML =
this JavaScript/JQuery:
console.log($(this.nextSibling.data));
logs to the console
I have tried:
console.log($(this.nextSibling.data.selector));
console.log($(this.nextSibling.data[selector]));
console.log($(this.nextSibling.data(selector)));
etc. without much luck. Since I'm not sure I even know what this data structure is, I don't know how to return " gi" (in this example) from the key-like-thing "selector:"
How can I get that string?
Simply use this.nextSibling.data
(without transforming it into a jQuery-object)
When this.nextSibling
is a textNode(or commentNode) it's data
-property returns the textContent (characterData) of this node.
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.