Home  >  Article  >  Web Front-end  >  How to get the value inside a DIV? _html/css_WEB-ITnose

How to get the value inside a DIV? _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:09:071078browse

0c6ec17a3adbe93e065dcd12ccfd26ce
                                           < ;/div>
16b28748ea4df4d9c2150843fecfba68

Get the three values ​​​​under the three parallel sub-DIVs. You need to remove line breaks and spaces. How to do this is to only get the three values ​​​​1, 2, and 3. number, and to get the same results on all browsers, please help. . . Thank you. The score is running out. . .


Reply to discussion (solution)

What does /d / mean? Is it a regular expression?

var obj = document.getElementById('firstDiv').getElementsByTagName('div');var result = [];for(var i = 0; i < obj.length; i ++) result.push(obj[i].innerHTML.match(/\d+/)[0]);alert(result);

JScript code

var obj = document.getElementById('firstDiv').getElementsByTagName('div');

var result = [];

for(var i = 0; i < obj.length; i ) result.push(obj[i].innerHTML.match(/d /)[0]);
alert(res……


/d / What does it mean? Is it a regular expression?
Regular expression, only matches numbers

Quote from 1st floor t5500’s reply:

JScript code

var obj = document. getElementById('firstDiv').getElementsByTagName('div');
var result = [];
for(var i = 0; i < obj.length; i ) result.push(obj[i] .innerHTML.matc……
1

0c6ec17a3adbe93e065dcd12ccfd26ce
;

                                                                                                          How to do it is to get the same results on all browsers. Thank you.

1

JScript code
var obj = document.getElementById('firstDiv').getElementsByTagName('div');
var result = [];
for(var i = 0; i < obj.length; i ) result.push(obj[i].innerHTML.match(/d /)[0]);
alert(r...

Correct solution

var result = [];

What does it mean?

Define an array

var result = [];
What does it mean?

Defining an array literal has the same effect as creating an array object through new Array().

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn