php javascript:用echo 输出div后获取value,该怎么解决

WBOY
Release: 2016-06-13 12:26:13
Original
963 people have browsed it

php javascript:用echo 输出div后获取value
//上面是从数据读取数据
//下面是输出div
echo "

";
echo "B: ".$row["b"];
?>
<script><br />function pop(w){<br /><br />alert(w.value);<br />}<br /></script>

//为什么会undefine?????
//谢谢!!
------解决思路----------------------
试试 w.getAttribute("value") 看看
------解决思路----------------------
.value属性是对于input来说的,你用div肯定不行,如果是 w.getAttribute("value")应该可以得到div的value。
------解决思路----------------------
改这样就可以了。
<br /><?php<br />$row['xxx'] = 100;<br />$row['b'] = 1;<br />echo "<div id='b' class='opdiv'  value='".$row['xxx']."'   onclick='pop(this)'>click</div>";<br />echo "B: ".$row["b"];<br />?><br /><script><br />function pop(w){<br />    alert(w.getAttribute('value'));<br />    //alert(w.value);<br />}<br /></script><br />
Copy after login
Related labels:
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