js获取html的span标签的值方法(超简单)
HTML中代码为:
<span id="testid">aaaa</span>
获取的js代码:
方法一:.innerText
var x1 = document.getElementById("testid").innerText; alert("x1="+x1);
方法二:.innerHTML
var x2 = document.getElementById("testid").innerHTML; alert("x2="+x2);
HTML中代码为:
<span id="testid">aaaa</span>
获取的js代码:
方法一:.innerText
var x1 = document.getElementById("testid").innerText; alert("x1="+x1);
方法二:.innerHTML
var x2 = document.getElementById("testid").innerHTML; alert("x2="+x2);