<div id="main">
<div class="navigate">
<ul>
<li>
<a href="http://localhost/xm/index.php"><span>xm</span></a> »
</li>
<li>
<a href="http://localhost/xm/index.php?action=admin"><span>Admin</span></a> »
</li>
<li>
<a href="http://localhost/xm/index.php?action=admin;change=name;random02342=randomvaluetoo320230"><span>change</span></a>
.......
从这个html代码中,我必须在变量中获取随机生成的数据“random02342=randomvaluetoo320230”,它也是随机生成的random0234和随机值。我如何通过 Javascript(或非 jquery)实现此目的?
编辑:random02342和randomvaluetoo320230是服务器端随机生成的..所以它就像每次新的哈希一样1stHash4324kjkjdas324324=And2ndAnotherHash324324asd23432
最佳答案
这会得到它,尽管它可能不会赢得任何优雅的奖项:
var m = document.getElementById('main').innerHTML.match(/random(\d+)=randomvaluetoo(\d+)/);
// m[1] and m[2] are the two random values.
关于javascript - 需要 DOM 操作帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12666154/