我有一个HTML页面。在我的头部分我有以下代码
<link href="/Content/css/Stylesheet1.css" rel="stylesheet" type="text/css">
<link href="/Content/css/jquery.datepick.css" rel="stylesheet" type="text/css">
<script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery/jquery.datepick.js" type="text/javascript"></script>
<script src="/Scripts/jquery/Script.js" type="text/javascript"></script>
如何将上述HTML元素的文件路径名更改为 下面一个使用动态jquery
<link href="http://localhost:9090/Content/css/Stylesheet1.css" rel="stylesheet" type="text/css">
<link href="http://localhost:9090/Content/css/jquery.datepick.css" rel="stylesheet" type="text/css">
<script src="http://localhost:9090/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="http://localhost:9090/Scripts/jquery/jquery.datepick.js" type="text/javascript"></script>
<script src="http://localhost:9090/Scripts/jquery/Script.js" type="text/javascript"></script
答案 0 :(得分:4)
$("link[href^='/Content/css']").attr('href', function(i, oldhref) {
return 'http://localhost:9090' + oldhref;
});
$("script[src^='/Scripts']").attr('src', function(i, oldsrc) {
return 'http://localhost:9090' + oldsrc;
});