Stop IE6 overwriting Button text when setting value.

Posted by RoToRa on Stack Overflow See other posts from Stack Overflow or by RoToRa
Published on 2010-05-25T16:06:48Z Indexed on 2010/05/25 16:11 UTC
Read the original article Hit count: 228

Filed under:
|
|
|
|

I've got a button which contains a span I need for styling:

<button id="example" name="example" value="Example"><span>Example</span></button>

IE6 has a bug that it submits the contents of the button instead of it's value, but I've already worked around that.

Now I need to change the value of the button and the text in the span in JavaScript/jQuery:

jQuery("#example").val("Changed").children("span").text("Changed");

However IE6 also changes the contents of the button when setting the value per JavaScript/jQuery, so that the span is lost.

Does any one know of a way other that identifying IE6 with jQuery.browser that I could use to avoid that?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery