471,605 Members | 1,434 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

Error in IE when inserting values to empty spans

11
When you insert value to an empty span in IE, the browser will not add the needed space between spans.

Example:

Expand|Select|Wrap|Line Numbers
  1. function btnclick()
  2. {
  3. document.getElementById("sp2").innerHTML="KING"
  4. }
  5. </script>
  6. <span id="sp1">Elvis</span>
  7. <span id="sp2"></span>
  8. <span id="sp3">Presley</span>
  9. <input type="button" onclick="btnclick()" />
  10.  


When you push the button, "KING" is inserted in the secong span, like this

Elvis KINGPresley

with no space between KING and Presley

Anyone knows a way around this?
Oct 30 '07 #1
7 1540
rrocket
116 100+
The quickest way is probably to just add a space before King for after Elvis... Like "Elvis " or " King".
Oct 30 '07 #2
drhowarddrfine
7,435 Expert 4TB
<span> is used to apply properties to the contents in between. You have no content so nothing happens. <span> cannot create content.
Oct 31 '07 #3
Stale
11
OK, but the main problem is that IE shows the result differently if YOU write "KING" inside the span or if the SCRIPT writes "KING" inside the span.
Nov 1 '07 #4
drhowarddrfine
7,435 Expert 4TB
It depends on when it is inserted between the spans. Is the property assigned and then you insert the text, or vice versa? If after the property is assigned, then that's the problem.
Nov 1 '07 #5
Stale
11
Thanks for your reply.

But: What property?
Nov 2 '07 #6
Stale
11
<span> is used to apply properties to the contents in between. You have no content so nothing happens. <span> cannot create content.
What propery?
How can I set this property?
Nov 15 '07 #7
drhowarddrfine
7,435 Expert 4TB
I meant the id which, I assume, is used to set a CSS property to the span.
Nov 15 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Wayno | last post: by
4 posts views Thread by Adrian | last post: by
9 posts views Thread by Andrew Banks | last post: by
6 posts views Thread by BaWork | last post: by
reply views Thread by pere | last post: by
Dormilich
2 posts views Thread by Dormilich | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.