Hi,
I'm trying to use the following code to change the href attribute of a div:
I can see that the alert pops up with "../index.html", but when I view the source code, it just shows <div id="subNav"></div>, the way it was before. Is the browser supposed to show the changed source code? I'm using Safari btw.
Thanks!
I'm trying to use the following code to change the href attribute of a div:
Code:
<html>
<head>
<title>Index</title>
</head>
<body>
<div id="subNav"></div>
<script type="text/javascript" charset="utf-8">
var subNav = document.getElementById('subNav');
subNav.setAttribute("href", "../index.html");
alert(subNav.href);
</script>
</body>
</html>
I can see that the alert pops up with "../index.html", but when I view the source code, it just shows <div id="subNav"></div>, the way it was before. Is the browser supposed to show the changed source code? I'm using Safari btw.
Thanks!