Home > Backend Development > PHP Tutorial > php javascript:用echo 输出div后获取value

php javascript:用echo 输出div后获取value

WBOY
Release: 2016-06-23 13:24:14
Original
1418 people have browsed it

//上面是从数据读取数据
//下面是输出div
echo "

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

//为什么会undefine?????
//谢谢!!


回复讨论(解决方案)

alert(w.id) 就可以,w.value就不行。。。。是上面原因呢?

试试 w.getAttribute("value") 看看

.value属性是对于input来说的,你用div肯定不行,如果是 w.getAttribute("value")应该可以得到div的value。

改这样就可以了。

<?php$row['xxx'] = 100;$row['b'] = 1;echo "<div id='b' class='opdiv'  value='".$row['xxx']."'   onclick='pop(this)'>click</div>";echo "B: ".$row["b"];?><script>function pop(w){    alert(w.getAttribute('value'));    //alert(w.value);}</script>
Copy after login

谢谢上面各位老大!

各位老大,如何继续通过js 把 当前的div 隐藏起来呢???谢谢!

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