Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
160
rated 0 times [  164] [ 4]  / answers: 1 / hits: 40141  / 10 Years ago, sun, january 18, 2015, 12:00:00

I have a feed that is outputting content dynamically to an element. I want to take the text from element A and output it to the console log.



Example:



<div class=elementa>ID5667</div>


Console Output:



ID : ID5667



I've tried a few things, but I'm either getting undefined or the full HTML of that element.


More From » jquery

 Answers
7

I think below should work for you.



var result = document.getElementsByClassName(elementa)[0].innerHTML;

console.log(result);


For more reference : getElementByClassName


[#68170] Thursday, January 15, 2015, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackelyn

Total Points: 303
Total Questions: 103
Total Answers: 102

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
jackelyn questions
Thu, Apr 8, 21, 00:00, 3 Years ago
Sun, Feb 28, 21, 00:00, 3 Years ago
Mon, May 25, 20, 00:00, 4 Years ago
Thu, Apr 30, 20, 00:00, 4 Years ago
;