Problem with span, p, and style.display=none

Have A Problem with Google Chrome? Post it here and hopefully someone can help!

Problem with span, p, and style.display=none

Postby rlokers on Sun Sep 06, 2009 1:54 am

In my webpage I have a span-tag that I hide and show using Javascript. In all other browsers this worked fine but not with Chrome. The problem appeared to be a p-tag within the span...

Just try this:

<html>
<body>
<span id='divX'><p>TEST</span>
END
<script>
document.getElementById('divX').style.display = 'none';
alert('you should see only END now');
document.getElementById('divX').style.display = 'block';
</script>
</body>
</html>

With the <p> within the span, the word END doesn't show in Chrome when the span has display=none. Remove the <p> and it all works as expected.
rlokers
 
Posts: 1
Joined: Sun Sep 06, 2009 1:50 am

Re: Problem with span, p, and style.display=none

Postby ebingeorge2009 on Sun Sep 06, 2009 9:54 am

Add a closing tag for <p> after TEST and before </span>.

<html>
<body>
<span id='divX' display="none"><p>TEST</p></span>
END
<script>
document.getElementById('divX').style.display = 'none';
alert('you should see only END now');
document.getElementById('divX').style.display = 'block';
</script>
</body>
</html>
ebingeorge2009
 
Posts: 3
Joined: Mon Aug 03, 2009 6:25 am


Return to Google Chrome Problems

Who is online

Users browsing this forum: No registered users and 1 guest

cron