<a id="q" href="/soft/soft.exe">4654456</a>
<a id="q" href="/soft/soft2.exe">654645645654</a><script type="text/javascript">
   document.getElementById('q').href='/soft/soft_' + Math.random().toString().slice(-6) + '.exe';
</script> ------
<a id="q" href="/soft/soft2.exe">654645645654</a> 这行 不修改ID=“q” 的情况下如何调用?

解决方案 »

  1.   

    <head>
    <script>
    function abc(XelementId)
    {
        document.getElementById(XelementId).href='/soft/soft_' + Math.random().toString().slice(-6) + '.exe';
    }
    </script>
    </head>
    <body>
    <a id="p" href="/soft/soft.exe">4654456</a>
    <a id="q" href="/soft/soft2.exe">654645645654</a>
    <script>abc("p")</script>
    <script>abc("q")</script>
    ...
      

  2.   


    这个方法还是不行,需要 <a id="q"  这里还是要修改  我是想 不需要修改这里 能达到每个ID 调用一个script