小编Mik*_*key的帖子

使用javascript更改链接标记的href

您好我正在尝试更改链接标记的href,以便在按下按钮时加载新的样式表.这是我到目前为止 -

function addcss()
{   
   var findlink = document.getElementsByTagName("link");
   findlink.href = "stylesheetxhtml.css";
}
Run Code Online (Sandbox Code Playgroud)

任何帮助非常感谢谢谢

html javascript css href link-tag

2
推荐指数
1
解决办法
1万
查看次数

带有多个语句的JavaScript`if`

为什么顶部代码有效而底部代码无效?

这个工作:

var i=1
function next() {
    document.getElementById("photo").src = "http://www.Example.com/images/" + jsArray[i];
    if (i<jsArray.length-2) 
        i++
    else
        i=0
}
Run Code Online (Sandbox Code Playgroud)

这个不起作用:

var i=1
function next() {
    if (i<jsArray.length-2) 
        i++
        document.getElementById("photo").src = "http://www.Example.com/images/" + jsArray[i];
    else
        i=0
        document.getElementById("photo").src = "http://www.Example.com/images/" + jsArray[i];
}
Run Code Online (Sandbox Code Playgroud)

javascript if-statement

-1
推荐指数
1
解决办法
62
查看次数

我无法让jQuery工作

嗨,我试图尝试一些jQuery,没有运气.正在编写代码,什么不是,没有什么工作.所以我从w3schools尝试了一些JQuery,甚至没有工作.知道为什么我不能让它工作吗?

我把它放在我的html的头上

 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>  
Run Code Online (Sandbox Code Playgroud)

仍然无法正常工作.

感谢任何帮助谢谢Mikey

<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeIn();
$("#div2").fadeIn("slow");
$("#div3").fadeIn(3000);
});
});
</script>
</head>

<body>
<p>Demonstrate fadeIn() with different parameters.</p>
<button>Click to fade in boxes</button>
<br><br>
<div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div>        <br>
<div id="div2" style="width:80px;height:80px;display:none;background-color:green;">    </div><br>
<div id="div3" style="width:80px;height:80px;display:none;background-color:blue;">  </div>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

把它复制到记事本中,然后将其保存,然后用铬合金运行,当我按下按钮时没有发生任何事情.

感谢所有帮助的人

jquery

-4
推荐指数
1
解决办法
6427
查看次数

标签 统计

javascript ×2

css ×1

href ×1

html ×1

if-statement ×1

jquery ×1

link-tag ×1