Problem with nested div

Posted in dotnet, vb, vb.net | No Comments »

I have the following javascript code:

alert(document.getElementById(‘contentDivContent’));

The content of the alert popup varies according to how I structure my HTML.

As expected, the popup shows "[object]" when my html looks like this:

<td class="contentTableContentCell">
<div id="contentDiv" class="text" onresize="positionLogos();">
</div>
<div id="contentDivContent">
&nbsp;
</div>
</td>

Unexpectedly, the popup shows "null" when my html looks like this:

<td class="contentTableContentCell">
<div id="contentDiv" class="text" onresize="positionLogos();">
<div id="contentDivContent">
&nbsp;
</div>
</div>
</td>

Can anyone help me understand why the popup shows "null" in the second example (where I nest the div I’m interested in inside another div)?

Cheers,
Jimmy

Similar:

  1. jQuery Get the second or x div with certain class This should be simple, but I can’t figure it out For example, lets assume the class .contentdiv is what were searching for. I want to...
  2. Message Passing in Chrome Hi All, Have a small doubt in how message passing works in chrome using content scrips. I modified the default example (http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/messaging/timer/) for message passing...
  3. Jquery inside a PopupControlExtender Hello, still problem with popup contro, I have  a popup that load dynamically the content using a web method, and I need to use the...
  4. nested user controls and javascript getElementById I've got a basic web form page which I use 2 user controls on. The first control has the second nested within it… On my...
  5. Referencing identical id’s in nested iFrames Here’s my problem: I have groups of elements that are scattered around my page but have identical id’s so that I can reference them all...

Leave a Reply