Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我包括带有参数的javascript:
<script type="text/javascript" src="js/app.min.js?ver=1.13"></script>
ver如何从此脚本中获取变量的值?
ver
试试这个: 在脚本标签中添加一个 id:
<script type="text/javascript" src="js/app.min.js?ver=1.13" id="script_id"></script>
进而:
var src=document.getElementById("script_id").src; alert(src.split("ver=")[1]);
请注意,我假设有一个参数,这个参数是 ver。