This is my code but for some reason the innerHTML is not changing the content inside of my content_holder div, help would be appreciated!
这是我的代码,但是由于某些原因,innerHTML没有改变我的content_holder div中的内容,帮助将会被欣赏!
I have tried multiple approaches and have done a lot of research and I have not been able to fix this error.
我已经尝试了多种方法并且做了大量的研究,我还没有能够修正这个错误。
<head>
<link rel="stylesheet" href="styles/default.css" />
</head>
<script type="text/javascript" src="jquery/jquery.js"></script>
<script type="text/javascript">
function news_clicked(){
$("#content_holder").fadeOut(200);
document.getElementById("#content_holder").innerHTML=("<?php("news_include.php"); ?>");
$("#content_holder").fadeIn(200);
}
</script>
<body>
<header id="header_bar">
<div id="top_holder">
<div id="top_holder_left">
<a id="logo"></a>
</div>
<div id="top_holder_right">
<a class="nav_button" href="#">HOME</a>
<a class="nav_button" onclick="news_clicked()" href="#">NEWS</a>
<a class="nav_button" href="#">GIGS</a>
<a class="nav_button" href="#">MUSIC</a>
<a class="nav_button" href="#">VIDEOS</a>
<a class="nav_button" href="#">SOCIAL</a>
</div>
</div>
</header>
<div id="content_holder">
<?php include("music_include.php"); ?>
</div>
</body>
2 个解决方案
#1
3
You have to use
你必须使用
document.getElementById("content_holder")
Instead of
而不是
document.getElementById("#content_holder")
as #
doesn't apply for getElementById
. This method expects a plain element id and not a selector.
因为#不应用于getElementById。该方法期望一个简单的元素id而不是一个选择器。
#2
0
Every time I have seen this error it has been a cheesy mistake on my part where I try to call an id for a div that does not exist on that page. Make sure the element you are trying to call exists on the page you are trying to change.
每当我看到这个错误时,我就会在我的部分尝试调用一个不存在于该页面上的div的id。确保您正在尝试调用的元素存在于正在尝试更改的页面上。
#1
3
You have to use
你必须使用
document.getElementById("content_holder")
Instead of
而不是
document.getElementById("#content_holder")
as #
doesn't apply for getElementById
. This method expects a plain element id and not a selector.
因为#不应用于getElementById。该方法期望一个简单的元素id而不是一个选择器。
#2
0
Every time I have seen this error it has been a cheesy mistake on my part where I try to call an id for a div that does not exist on that page. Make sure the element you are trying to call exists on the page you are trying to change.
每当我看到这个错误时,我就会在我的部分尝试调用一个不存在于该页面上的div的id。确保您正在尝试调用的元素存在于正在尝试更改的页面上。