使用setAttribute到href链接

时间:2017-09-25 22:01:07

标签: javascript html icons setattribute

Heyo!我正在使用随机数生成器来选择图标。然后我将它设置为setAttribute()。试图设置它不起作用。我做错了什么?

<!DOCTYPE html>

<html>
<head>
<script type="text/javascript">


    var number = Math.floor((Math.random() * 5) + 1);

    var ico = number + ".ico"


    setAttribute(href, ico);




</script>
<title>Cool Server People!</title>
<link rel="stylesheet" href="style.css">
<link rel="shortcut icon" href= "1.ico"/>
</head>
<body>
<div class="header">
    <h1>Cool Server People</h1>
</div>

<div class="space">

</div>  

<div class="blog">

    <a href="test-post.html" class="post">Blog Post</a>
    <p>asdfdasdfasdfasdfa</p>

</div>

0 个答案:

没有答案