JQuery -.text () ,. html () does not work on IE8

Here is a link to the code and jsfiddle. I tried .text and .html both functions. But both do not work on IE8. Can someone provide me a solution for IE? (I googled and people seem to have similar problems, but can't get a solution) Thanks.

http://jsfiddle.net/3eaGL/

<div class="controls"> <div class="btn-group" data-toggle="buttons-radio"> <input name="MySecurity[my_education]" id="MySecurity_my_education" type="hidden" value="0" /> <button type="button" class="btn" value="2" display="Private">P</button> <button type="button" class="btn" value="1" display="Friends">F</button> <button type="button" class="btn" value="0" display="All ( Public )">A</button> </div> <text class="mySecurityDisplay"></text> </div> $("button[display]").bind('click', function(){ var buttonValue=this.value; $(this).siblings("input[type=hidden]").val(buttonValue); $(this).parent().next().text($(this).attr( 'display' )); }); 
+4
source share
4 answers

Your problem is the <text> . This is an invalid HTML tag. IE below version 9 interprets unknown tags in this way: <text class="mySecurityDisplay"></text> becomes <text class="mySecurityDisplay"/><text/> a, so you won’t be able to paste content into it.

Just write <div class="mySecurityDisplay"></div> , it will work.

+4
source

The problem is this:

 <text class="mySecurityDisplay"></text> 

IE8 does not display unknown tags, so jQuery does not select your element, the problem is not related to the html or text method. Use a valid tag instead, and your code will work.

+7
source

Ok, I worked, the problem was the <text> element

http://jsfiddle.net/3eaGL/7/

Jquery created the instance object after selecting the <text> element, but since its invalid HTML tag, the JQuery object will not return any methods for your removal.

This is similar to trying to make a val() element in a <span> , but only valid on html form elements.

+1
source
  • Check if you have valid html, there may be inappropriate tags.

  • Try using append instead of html method.

0
source

All Articles