开发没用到js框架所以自己写了个函数来获取dom元素代码如下
<html> <body> <div class="qq">sesdsds</div> </body> <script> function getElementsByClassName(n) { var classElements = [],allElements = document.getElementsByTagName('*'); for (var i=0; i< allElements.length; i++ ) { if (allElements[i].className == n ) { classElements[classElements.length] = allElements[i]; } } return classElements; } var test=getElementsByClassName("qq")[0].innerText; alert(test); </script> </html>
?