Kumar
Kumar

Reputation: 417

jquery.find doesnt return data in ie 8

<H1 class=extraBottomMargin>Tell us the name of your employers</H1>
        <UIWIDGET>
            <FIELDSET>
                <DIV>
                    <INPUT id=viewEnterEmployerNames_q1 tabIndex=1 maxLength=75 placeholder="Employer">
                </DIV>
            </FIELDSET>
        </UIWIDGET>
        <DIV class="rightRail watermark"><IMG src="app/img/RR_Watermark.png"></div>

I run a command jQuery("above html").find("UIWIDGET").html()

This works in all browsers except IE 8. Please advice.

Note that uiwidget is my custom tag, so please ignore the part of suggesting any improvements on that.

Upvotes: 0

Views: 100

Answers (2)

Reflective
Reflective

Reputation: 3917

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:custom="http://www.test.com">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<body>
<H1 class=extraBottomMargin>Tell us the name of your employers</H1>
        <custom:uiwidget>
            <FIELDSET>
                <DIV>
                    <INPUT id=viewEnterEmployerNames_q1 tabIndex=1 maxLength=75 placeholder="Employer">
                </DIV>
            </FIELDSET>
        </custom:uiwidget>
        <DIV class="rightRail watermark"><IMG src="app/img/RR_Watermark.png"></div>
</body>

<script>    
$(function() {
   alert($("uiwidget").html());
});
</script>

This will work in IE but WON'T work in other browsers!!! That's the official way for IE to define and support custom tags. This reflects on .getElementsByTagName() method, so I see no way to search custom tags like <mytag> in IE doesn't matter if you use jQuery or other library or just directly invoking .getElementsByTagName(). Searching Google you can find many official and unofficial articles about this issue.

Upvotes: 0

ThiefMaster
ThiefMaster

Reputation: 318568

There is no HTML tag named UIWIDGET - and in older IE versions accessing non-standard tags won't work without creating them first.

You can easily do so by calling document.createElement('UIWIDGET') - that's what libraries such as html5shiv do for the HTML5 elements.

In case you plan to use some HTML5 tags anyway you could add html5shiv and run the following code before including the html5shiv script: html5.options.elements += ' uiwidget';

However, it would be much better if you did not use invalid HTML tags at all!

Upvotes: 2

Related Questions