-4
<h1>
    <span id="T-1">
        <div>1111</div>
        <div><h1>2222</h1></div>
        <div>33333</div>
    </span>
</h1>

I have this html code for replicating the issue in IE 9. I am using the following js code:

console.log($("#T-1").html());

The above code is not fetching the full inner html data. It is fetching some portion of html data. Can anyone have a look at this issue.

Console output is:

<div>1111</div><div></div>
10
  • 2
    What is printed to console? Give the result you see.
    – RaviH
    Mar 12, 2015 at 7:54
  • 2
    "It is fetching some portion of html data" And what, we're supposed to guess what portion that is? Mar 12, 2015 at 7:55
  • 1
    Note that putting a div inside a span is invalid, the browser is allowed to do whatever it wants to make it right. Mar 12, 2015 at 7:56
  • div is not a valid child of span. The browser will correct this by moving the div elements out of the span and the span will empty then.
    – t.niese
    Mar 12, 2015 at 7:56
  • "not fetching the full inner html data"...should fetch. IDs has to be unique do you have any other element with same id.
    – Jai
    Mar 12, 2015 at 7:56

1 Answer 1

0

You are nesting h4 inside h1 and it causing the error which you are getting. Write valid code like:

make all div to span

<h1 id="T-1">
    <span >1111</span >
    <span class="h4">2222</span >
    <span >33333</span >
</h1>

checkout his pen

4
  • @t.niese Agreed!, somehow browser manages to go with div inside span but it stops in console when you put h4 inside h1, If you've any doubts I recommend you to try out the same thing! :) Mar 12, 2015 at 8:18
  • @VilasKumkar, replace the <h4> tag with <h1> tag in my original html data. It will console this data: <div>1111</div><div></div> (i.e. some portion of original html structure). Also if you do the debug in IE9 browser, you can see that Jquery code is not working as expected...
    – TBasak
    Mar 12, 2015 at 8:48
  • @TBasak I'm not getting you, could you please elaborate more on this or update your code in question Mar 12, 2015 at 8:52
  • @TBasak Dude, "You are nesting h4 inside h1" it doesn't mean that you should try any "h*" tag inside h1 Mar 12, 2015 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.