使用 jquery 更改 HTML 元素的文件路径名



我有一个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
$("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;
});

最新更新