Home > Article > Web Front-end > How to get the value inside a DIV? _html/css_WEB-ITnose
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:
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
;
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
What does it mean?
Define an array
var result = [];
What does it mean?