Question

I have the following html code:

<mytag>
      Just Some Text
</mytag> 

And I have this jQuery command

$('mytag').each(function () { alert($(this).html()); });

In all browsers except IE I'm getting the inner HTML, in IE I'm not. Anyone can shed any light on this mystery? I've tested this with IE8, Mozilla, Opera, Chrome and Safari

Was it helpful?

Solution

Because Internet Explorer doesn't error correct for that particular type of invalid HTML in the same way that the other browsers you have tested the code with do.

I would imagine that you can hack around it (it works for applying CSS) with:

document.createElement('mytag')

… but you would be better off writing HTML (or writing XML and serving it as application/xml).

OTHER TIPS

For IE, you need put this in your tag -> xmlns='mytag'

<mytag xmlns='mytag'>
  Just Some Text
</mytag>

now IE and all other browsers can "see" your tag

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top