Getting all inner text of divs with same class
Is there way I can all inner html of all div with class="company Name".
Please guide me in right direction.
Edit
Can I use this in chrome console to get information out of a web page ?
javascript
add a comment |
Is there way I can all inner html of all div with class="company Name".
Please guide me in right direction.
Edit
Can I use this in chrome console to get information out of a web page ?
javascript
Are you after "inner text" or "innerHTML"? They are different things.
– RobG
Feb 17 '14 at 23:13
@RobG inner text to be exact :)
– Mathematics
Feb 17 '14 at 23:14
"Can I use this in chrome console" You can execute any JS code in the console.
– Felix Kling
Feb 17 '14 at 23:14
@FelixKling thanks, what if I want to generate output in a text file, sorry for question over question, but I am in bit rush, sorry :)
– Mathematics
Feb 17 '14 at 23:16
Then you copy and paste the output of the console.
– Felix Kling
Feb 17 '14 at 23:22
add a comment |
Is there way I can all inner html of all div with class="company Name".
Please guide me in right direction.
Edit
Can I use this in chrome console to get information out of a web page ?
javascript
Is there way I can all inner html of all div with class="company Name".
Please guide me in right direction.
Edit
Can I use this in chrome console to get information out of a web page ?
javascript
javascript
edited Feb 17 '14 at 23:13
Mathematics
asked Feb 17 '14 at 23:05
MathematicsMathematics
2,0981744105
2,0981744105
Are you after "inner text" or "innerHTML"? They are different things.
– RobG
Feb 17 '14 at 23:13
@RobG inner text to be exact :)
– Mathematics
Feb 17 '14 at 23:14
"Can I use this in chrome console" You can execute any JS code in the console.
– Felix Kling
Feb 17 '14 at 23:14
@FelixKling thanks, what if I want to generate output in a text file, sorry for question over question, but I am in bit rush, sorry :)
– Mathematics
Feb 17 '14 at 23:16
Then you copy and paste the output of the console.
– Felix Kling
Feb 17 '14 at 23:22
add a comment |
Are you after "inner text" or "innerHTML"? They are different things.
– RobG
Feb 17 '14 at 23:13
@RobG inner text to be exact :)
– Mathematics
Feb 17 '14 at 23:14
"Can I use this in chrome console" You can execute any JS code in the console.
– Felix Kling
Feb 17 '14 at 23:14
@FelixKling thanks, what if I want to generate output in a text file, sorry for question over question, but I am in bit rush, sorry :)
– Mathematics
Feb 17 '14 at 23:16
Then you copy and paste the output of the console.
– Felix Kling
Feb 17 '14 at 23:22
Are you after "inner text" or "innerHTML"? They are different things.
– RobG
Feb 17 '14 at 23:13
Are you after "inner text" or "innerHTML"? They are different things.
– RobG
Feb 17 '14 at 23:13
@RobG inner text to be exact :)
– Mathematics
Feb 17 '14 at 23:14
@RobG inner text to be exact :)
– Mathematics
Feb 17 '14 at 23:14
"Can I use this in chrome console" You can execute any JS code in the console.
– Felix Kling
Feb 17 '14 at 23:14
"Can I use this in chrome console" You can execute any JS code in the console.
– Felix Kling
Feb 17 '14 at 23:14
@FelixKling thanks, what if I want to generate output in a text file, sorry for question over question, but I am in bit rush, sorry :)
– Mathematics
Feb 17 '14 at 23:16
@FelixKling thanks, what if I want to generate output in a text file, sorry for question over question, but I am in bit rush, sorry :)
– Mathematics
Feb 17 '14 at 23:16
Then you copy and paste the output of the console.
– Felix Kling
Feb 17 '14 at 23:22
Then you copy and paste the output of the console.
– Felix Kling
Feb 17 '14 at 23:22
add a comment |
5 Answers
5
active
oldest
votes
Please don't use jquery for this. It's very easy with plain ol' javascript.
var x = document.querySelectorAll("[class='company Name']");
for (var i=0;i<x.length;i++) {
//grab x[i].innerHTML (or textContent or innerText)
}
The selector can be ".someClass", which is less to type. ;-)
– RobG
Feb 17 '14 at 23:15
@RobG would it accept(".some .class")
as well?
– Sterling Archer
Feb 17 '14 at 23:16
The correct selector would be.same.class
..some .class
would look for all.class
descendants of.some
elements.
– Felix Kling
Feb 17 '14 at 23:22
add a comment |
JSFIDDLE
OPTION 1 - A one-liner
var innerHTMLs = Array.prototype.slice.call( document.getElementsByClassName( 'company_name' ) ).map( function( x ){ return x.innerHTML } );
console.log( innerHTMLs );
OPTION 2 - Slightly more verbose.
var elements = document.getElementsByClassName( 'company_name' ),
innerHTMLs = ;
for ( var i = 0; i < elements.length; ++i )
innerHTMLs.push( elements[i].innerHTML );
console.log( innerHTMLs );
OPTION 3 - Should work on older browsers (IE8 and earlier) too.
var innerHTMLs = ,
elements = document.getElementsByTagName( '*' ),
classToMatch = 'bob';
for ( var i = 0; i < elements.length; ++i )
{
if ( ( ' ' + elements[i].className + ' ' ).indexOf( ' ' + classToMatch + ' ' ) != -1 )
innerHTMLs.push( elements[i].innerHTML );
}
console.log( innerHTMLs );
Class values are separated by space,b
will match end of words so will splitcompany-name
into two tokens when it should be one. The regular expression should be built using'(^|\s+)' + className + '(\s+|$)'
.
– RobG
Feb 18 '14 at 2:59
add a comment |
You'd probably want to start with this:
var elements = document.getElementsByClassName('company name');
Then elements will be an array of all your divs.
After than iterate through them using a 'for in' and pull out the inner html for each one. Maybe something like this:
var allInnerHTML = '';
for (index in elements)
{
var element = elements[index];
allInnerHTML = allInnerHTML + element.innerHTML;
}
Not sure exactly what you're wanting to do but hopefully this will help.
1
If you are going to do for..in iteration over a host object (here a NodeList, which is not a good idea in this case), you must do a hasOwnProperty check and also check the property name is numeric to exclude unexpected properties and those that don't have a DOM element reference as the value. Given all that, it is much easier to do a normal iterative loop over the collection using an imcrementing counter (e.g.for (var i=0; i<elements.length; i++)
so that you are guaranteed a DOM element every time.
– RobG
Feb 18 '14 at 2:53
Thanks for the insight!
– Maxwell's Demon
Feb 18 '14 at 6:03
add a comment |
You could store all the strings in an array using jQuery:
var strings = ;
$('.yourclass').each(function(){
strings.push( $(this).text() );
});
5
From thejavascript
tag description: "Unless a tag for a framework/library is also included, a pure JavaScript answer is expected." Please provide a non-jQuery solution as well.
– Felix Kling
Feb 17 '14 at 23:12
add a comment |
You can obtain an array of innerText
from elements containing class="company Name"
using the following method:
Array.from(document.getElementsByClassName('company Name'), e => e.innerText)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21841079%2fgetting-all-inner-text-of-divs-with-same-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Please don't use jquery for this. It's very easy with plain ol' javascript.
var x = document.querySelectorAll("[class='company Name']");
for (var i=0;i<x.length;i++) {
//grab x[i].innerHTML (or textContent or innerText)
}
The selector can be ".someClass", which is less to type. ;-)
– RobG
Feb 17 '14 at 23:15
@RobG would it accept(".some .class")
as well?
– Sterling Archer
Feb 17 '14 at 23:16
The correct selector would be.same.class
..some .class
would look for all.class
descendants of.some
elements.
– Felix Kling
Feb 17 '14 at 23:22
add a comment |
Please don't use jquery for this. It's very easy with plain ol' javascript.
var x = document.querySelectorAll("[class='company Name']");
for (var i=0;i<x.length;i++) {
//grab x[i].innerHTML (or textContent or innerText)
}
The selector can be ".someClass", which is less to type. ;-)
– RobG
Feb 17 '14 at 23:15
@RobG would it accept(".some .class")
as well?
– Sterling Archer
Feb 17 '14 at 23:16
The correct selector would be.same.class
..some .class
would look for all.class
descendants of.some
elements.
– Felix Kling
Feb 17 '14 at 23:22
add a comment |
Please don't use jquery for this. It's very easy with plain ol' javascript.
var x = document.querySelectorAll("[class='company Name']");
for (var i=0;i<x.length;i++) {
//grab x[i].innerHTML (or textContent or innerText)
}
Please don't use jquery for this. It's very easy with plain ol' javascript.
var x = document.querySelectorAll("[class='company Name']");
for (var i=0;i<x.length;i++) {
//grab x[i].innerHTML (or textContent or innerText)
}
answered Feb 17 '14 at 23:10
Sterling ArcherSterling Archer
15.9k115888
15.9k115888
The selector can be ".someClass", which is less to type. ;-)
– RobG
Feb 17 '14 at 23:15
@RobG would it accept(".some .class")
as well?
– Sterling Archer
Feb 17 '14 at 23:16
The correct selector would be.same.class
..some .class
would look for all.class
descendants of.some
elements.
– Felix Kling
Feb 17 '14 at 23:22
add a comment |
The selector can be ".someClass", which is less to type. ;-)
– RobG
Feb 17 '14 at 23:15
@RobG would it accept(".some .class")
as well?
– Sterling Archer
Feb 17 '14 at 23:16
The correct selector would be.same.class
..some .class
would look for all.class
descendants of.some
elements.
– Felix Kling
Feb 17 '14 at 23:22
The selector can be ".someClass", which is less to type. ;-)
– RobG
Feb 17 '14 at 23:15
The selector can be ".someClass", which is less to type. ;-)
– RobG
Feb 17 '14 at 23:15
@RobG would it accept
(".some .class")
as well?– Sterling Archer
Feb 17 '14 at 23:16
@RobG would it accept
(".some .class")
as well?– Sterling Archer
Feb 17 '14 at 23:16
The correct selector would be
.same.class
. .some .class
would look for all .class
descendants of .some
elements.– Felix Kling
Feb 17 '14 at 23:22
The correct selector would be
.same.class
. .some .class
would look for all .class
descendants of .some
elements.– Felix Kling
Feb 17 '14 at 23:22
add a comment |
JSFIDDLE
OPTION 1 - A one-liner
var innerHTMLs = Array.prototype.slice.call( document.getElementsByClassName( 'company_name' ) ).map( function( x ){ return x.innerHTML } );
console.log( innerHTMLs );
OPTION 2 - Slightly more verbose.
var elements = document.getElementsByClassName( 'company_name' ),
innerHTMLs = ;
for ( var i = 0; i < elements.length; ++i )
innerHTMLs.push( elements[i].innerHTML );
console.log( innerHTMLs );
OPTION 3 - Should work on older browsers (IE8 and earlier) too.
var innerHTMLs = ,
elements = document.getElementsByTagName( '*' ),
classToMatch = 'bob';
for ( var i = 0; i < elements.length; ++i )
{
if ( ( ' ' + elements[i].className + ' ' ).indexOf( ' ' + classToMatch + ' ' ) != -1 )
innerHTMLs.push( elements[i].innerHTML );
}
console.log( innerHTMLs );
Class values are separated by space,b
will match end of words so will splitcompany-name
into two tokens when it should be one. The regular expression should be built using'(^|\s+)' + className + '(\s+|$)'
.
– RobG
Feb 18 '14 at 2:59
add a comment |
JSFIDDLE
OPTION 1 - A one-liner
var innerHTMLs = Array.prototype.slice.call( document.getElementsByClassName( 'company_name' ) ).map( function( x ){ return x.innerHTML } );
console.log( innerHTMLs );
OPTION 2 - Slightly more verbose.
var elements = document.getElementsByClassName( 'company_name' ),
innerHTMLs = ;
for ( var i = 0; i < elements.length; ++i )
innerHTMLs.push( elements[i].innerHTML );
console.log( innerHTMLs );
OPTION 3 - Should work on older browsers (IE8 and earlier) too.
var innerHTMLs = ,
elements = document.getElementsByTagName( '*' ),
classToMatch = 'bob';
for ( var i = 0; i < elements.length; ++i )
{
if ( ( ' ' + elements[i].className + ' ' ).indexOf( ' ' + classToMatch + ' ' ) != -1 )
innerHTMLs.push( elements[i].innerHTML );
}
console.log( innerHTMLs );
Class values are separated by space,b
will match end of words so will splitcompany-name
into two tokens when it should be one. The regular expression should be built using'(^|\s+)' + className + '(\s+|$)'
.
– RobG
Feb 18 '14 at 2:59
add a comment |
JSFIDDLE
OPTION 1 - A one-liner
var innerHTMLs = Array.prototype.slice.call( document.getElementsByClassName( 'company_name' ) ).map( function( x ){ return x.innerHTML } );
console.log( innerHTMLs );
OPTION 2 - Slightly more verbose.
var elements = document.getElementsByClassName( 'company_name' ),
innerHTMLs = ;
for ( var i = 0; i < elements.length; ++i )
innerHTMLs.push( elements[i].innerHTML );
console.log( innerHTMLs );
OPTION 3 - Should work on older browsers (IE8 and earlier) too.
var innerHTMLs = ,
elements = document.getElementsByTagName( '*' ),
classToMatch = 'bob';
for ( var i = 0; i < elements.length; ++i )
{
if ( ( ' ' + elements[i].className + ' ' ).indexOf( ' ' + classToMatch + ' ' ) != -1 )
innerHTMLs.push( elements[i].innerHTML );
}
console.log( innerHTMLs );
JSFIDDLE
OPTION 1 - A one-liner
var innerHTMLs = Array.prototype.slice.call( document.getElementsByClassName( 'company_name' ) ).map( function( x ){ return x.innerHTML } );
console.log( innerHTMLs );
OPTION 2 - Slightly more verbose.
var elements = document.getElementsByClassName( 'company_name' ),
innerHTMLs = ;
for ( var i = 0; i < elements.length; ++i )
innerHTMLs.push( elements[i].innerHTML );
console.log( innerHTMLs );
OPTION 3 - Should work on older browsers (IE8 and earlier) too.
var innerHTMLs = ,
elements = document.getElementsByTagName( '*' ),
classToMatch = 'bob';
for ( var i = 0; i < elements.length; ++i )
{
if ( ( ' ' + elements[i].className + ' ' ).indexOf( ' ' + classToMatch + ' ' ) != -1 )
innerHTMLs.push( elements[i].innerHTML );
}
console.log( innerHTMLs );
edited Feb 18 '14 at 7:12
answered Feb 17 '14 at 23:25
MT0MT0
52.1k52756
52.1k52756
Class values are separated by space,b
will match end of words so will splitcompany-name
into two tokens when it should be one. The regular expression should be built using'(^|\s+)' + className + '(\s+|$)'
.
– RobG
Feb 18 '14 at 2:59
add a comment |
Class values are separated by space,b
will match end of words so will splitcompany-name
into two tokens when it should be one. The regular expression should be built using'(^|\s+)' + className + '(\s+|$)'
.
– RobG
Feb 18 '14 at 2:59
Class values are separated by space,
b
will match end of words so will split company-name
into two tokens when it should be one. The regular expression should be built using '(^|\s+)' + className + '(\s+|$)'
.– RobG
Feb 18 '14 at 2:59
Class values are separated by space,
b
will match end of words so will split company-name
into two tokens when it should be one. The regular expression should be built using '(^|\s+)' + className + '(\s+|$)'
.– RobG
Feb 18 '14 at 2:59
add a comment |
You'd probably want to start with this:
var elements = document.getElementsByClassName('company name');
Then elements will be an array of all your divs.
After than iterate through them using a 'for in' and pull out the inner html for each one. Maybe something like this:
var allInnerHTML = '';
for (index in elements)
{
var element = elements[index];
allInnerHTML = allInnerHTML + element.innerHTML;
}
Not sure exactly what you're wanting to do but hopefully this will help.
1
If you are going to do for..in iteration over a host object (here a NodeList, which is not a good idea in this case), you must do a hasOwnProperty check and also check the property name is numeric to exclude unexpected properties and those that don't have a DOM element reference as the value. Given all that, it is much easier to do a normal iterative loop over the collection using an imcrementing counter (e.g.for (var i=0; i<elements.length; i++)
so that you are guaranteed a DOM element every time.
– RobG
Feb 18 '14 at 2:53
Thanks for the insight!
– Maxwell's Demon
Feb 18 '14 at 6:03
add a comment |
You'd probably want to start with this:
var elements = document.getElementsByClassName('company name');
Then elements will be an array of all your divs.
After than iterate through them using a 'for in' and pull out the inner html for each one. Maybe something like this:
var allInnerHTML = '';
for (index in elements)
{
var element = elements[index];
allInnerHTML = allInnerHTML + element.innerHTML;
}
Not sure exactly what you're wanting to do but hopefully this will help.
1
If you are going to do for..in iteration over a host object (here a NodeList, which is not a good idea in this case), you must do a hasOwnProperty check and also check the property name is numeric to exclude unexpected properties and those that don't have a DOM element reference as the value. Given all that, it is much easier to do a normal iterative loop over the collection using an imcrementing counter (e.g.for (var i=0; i<elements.length; i++)
so that you are guaranteed a DOM element every time.
– RobG
Feb 18 '14 at 2:53
Thanks for the insight!
– Maxwell's Demon
Feb 18 '14 at 6:03
add a comment |
You'd probably want to start with this:
var elements = document.getElementsByClassName('company name');
Then elements will be an array of all your divs.
After than iterate through them using a 'for in' and pull out the inner html for each one. Maybe something like this:
var allInnerHTML = '';
for (index in elements)
{
var element = elements[index];
allInnerHTML = allInnerHTML + element.innerHTML;
}
Not sure exactly what you're wanting to do but hopefully this will help.
You'd probably want to start with this:
var elements = document.getElementsByClassName('company name');
Then elements will be an array of all your divs.
After than iterate through them using a 'for in' and pull out the inner html for each one. Maybe something like this:
var allInnerHTML = '';
for (index in elements)
{
var element = elements[index];
allInnerHTML = allInnerHTML + element.innerHTML;
}
Not sure exactly what you're wanting to do but hopefully this will help.
answered Feb 17 '14 at 23:13
Maxwell's DemonMaxwell's Demon
199110
199110
1
If you are going to do for..in iteration over a host object (here a NodeList, which is not a good idea in this case), you must do a hasOwnProperty check and also check the property name is numeric to exclude unexpected properties and those that don't have a DOM element reference as the value. Given all that, it is much easier to do a normal iterative loop over the collection using an imcrementing counter (e.g.for (var i=0; i<elements.length; i++)
so that you are guaranteed a DOM element every time.
– RobG
Feb 18 '14 at 2:53
Thanks for the insight!
– Maxwell's Demon
Feb 18 '14 at 6:03
add a comment |
1
If you are going to do for..in iteration over a host object (here a NodeList, which is not a good idea in this case), you must do a hasOwnProperty check and also check the property name is numeric to exclude unexpected properties and those that don't have a DOM element reference as the value. Given all that, it is much easier to do a normal iterative loop over the collection using an imcrementing counter (e.g.for (var i=0; i<elements.length; i++)
so that you are guaranteed a DOM element every time.
– RobG
Feb 18 '14 at 2:53
Thanks for the insight!
– Maxwell's Demon
Feb 18 '14 at 6:03
1
1
If you are going to do for..in iteration over a host object (here a NodeList, which is not a good idea in this case), you must do a hasOwnProperty check and also check the property name is numeric to exclude unexpected properties and those that don't have a DOM element reference as the value. Given all that, it is much easier to do a normal iterative loop over the collection using an imcrementing counter (e.g.
for (var i=0; i<elements.length; i++)
so that you are guaranteed a DOM element every time.– RobG
Feb 18 '14 at 2:53
If you are going to do for..in iteration over a host object (here a NodeList, which is not a good idea in this case), you must do a hasOwnProperty check and also check the property name is numeric to exclude unexpected properties and those that don't have a DOM element reference as the value. Given all that, it is much easier to do a normal iterative loop over the collection using an imcrementing counter (e.g.
for (var i=0; i<elements.length; i++)
so that you are guaranteed a DOM element every time.– RobG
Feb 18 '14 at 2:53
Thanks for the insight!
– Maxwell's Demon
Feb 18 '14 at 6:03
Thanks for the insight!
– Maxwell's Demon
Feb 18 '14 at 6:03
add a comment |
You could store all the strings in an array using jQuery:
var strings = ;
$('.yourclass').each(function(){
strings.push( $(this).text() );
});
5
From thejavascript
tag description: "Unless a tag for a framework/library is also included, a pure JavaScript answer is expected." Please provide a non-jQuery solution as well.
– Felix Kling
Feb 17 '14 at 23:12
add a comment |
You could store all the strings in an array using jQuery:
var strings = ;
$('.yourclass').each(function(){
strings.push( $(this).text() );
});
5
From thejavascript
tag description: "Unless a tag for a framework/library is also included, a pure JavaScript answer is expected." Please provide a non-jQuery solution as well.
– Felix Kling
Feb 17 '14 at 23:12
add a comment |
You could store all the strings in an array using jQuery:
var strings = ;
$('.yourclass').each(function(){
strings.push( $(this).text() );
});
You could store all the strings in an array using jQuery:
var strings = ;
$('.yourclass').each(function(){
strings.push( $(this).text() );
});
edited Feb 17 '14 at 23:16
answered Feb 17 '14 at 23:07
Stefano OrtisiStefano Ortisi
4,28522335
4,28522335
5
From thejavascript
tag description: "Unless a tag for a framework/library is also included, a pure JavaScript answer is expected." Please provide a non-jQuery solution as well.
– Felix Kling
Feb 17 '14 at 23:12
add a comment |
5
From thejavascript
tag description: "Unless a tag for a framework/library is also included, a pure JavaScript answer is expected." Please provide a non-jQuery solution as well.
– Felix Kling
Feb 17 '14 at 23:12
5
5
From the
javascript
tag description: "Unless a tag for a framework/library is also included, a pure JavaScript answer is expected." Please provide a non-jQuery solution as well.– Felix Kling
Feb 17 '14 at 23:12
From the
javascript
tag description: "Unless a tag for a framework/library is also included, a pure JavaScript answer is expected." Please provide a non-jQuery solution as well.– Felix Kling
Feb 17 '14 at 23:12
add a comment |
You can obtain an array of innerText
from elements containing class="company Name"
using the following method:
Array.from(document.getElementsByClassName('company Name'), e => e.innerText)
add a comment |
You can obtain an array of innerText
from elements containing class="company Name"
using the following method:
Array.from(document.getElementsByClassName('company Name'), e => e.innerText)
add a comment |
You can obtain an array of innerText
from elements containing class="company Name"
using the following method:
Array.from(document.getElementsByClassName('company Name'), e => e.innerText)
You can obtain an array of innerText
from elements containing class="company Name"
using the following method:
Array.from(document.getElementsByClassName('company Name'), e => e.innerText)
edited Nov 21 '18 at 23:57
answered May 17 '18 at 19:58
Grant MillerGrant Miller
5,462132850
5,462132850
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21841079%2fgetting-all-inner-text-of-divs-with-same-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you after "inner text" or "innerHTML"? They are different things.
– RobG
Feb 17 '14 at 23:13
@RobG inner text to be exact :)
– Mathematics
Feb 17 '14 at 23:14
"Can I use this in chrome console" You can execute any JS code in the console.
– Felix Kling
Feb 17 '14 at 23:14
@FelixKling thanks, what if I want to generate output in a text file, sorry for question over question, but I am in bit rush, sorry :)
– Mathematics
Feb 17 '14 at 23:16
Then you copy and paste the output of the console.
– Felix Kling
Feb 17 '14 at 23:22