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

WBOY
Release: 2016-06-24 12:09:07
Original
1079 people have browsed it


                                           < ;/div>


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);
Copy after login

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


;

                                                                                                          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().

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template