This has been asked many times, I've found many other questions like this. None of which has helped me. I can't find the problem in my code and it's about to drive me insane.
Most answers say that there is a typo on my id name. However, I've changed the id name quite a few times and pasted it to no avail.
<div id="room_footer" class="d-block m-za std-border">
<span class="pl10 cur-p" onClick="embedToggle()">
Click here
</span>
<br/>
<div id"123222" class="w275p h120p ml10 d-inline c-l cur-p">
<textarea class="w250p h100p"></textarea>
<p></p>
</div>
<span class="f-right pr10"><a href="">Click Here</a></span>
</div>
Javascript. I've tried this with straight JS and jQuery both. Neither of which work.
<script type="text/javascript">
function embedToggle() {
var id = "123222";
var obj = document.getElementById(id).style.display;
alert(obj);
if(obj == "none") {
obj = "inline-block";
} else {
obj = "none";
}
}
</script>
There is something messed up and I can't find it. I've been working on this for about 2hrs now. Much too long for such a simple stupid mistake. Please help me.
Line should be:
<div id="id123222" class="w275p h120p ml10 d-inline c-l cur-p">
And you should add a letter to the beginning so that it is valid.
http://reference.sitepoint.com/html/core-attributes/id
UPDATE:
The id is valid for HTML5 per comment from @Ian.
<div id"123222"
should be
<div id="something-123222"
Check the comments about ID's not being numbers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.