Jump to content

Help with DOM


Fmdpa

Recommended Posts

I go through DOM so methodically, but somehow it still is smarter than me. I am trying to access the innerHTML value of the p.rating tag.

<div class="c_name">MyName    <span class='c_time'> on October 19, 2010 06:49 PM        <div id="hand_rate">            <img src="/PNG/down.png" class="thumb_rate" id="thumb_down" data-id="115" /> <!--from either of these img tags-->            <img src="/PNG/up.png" class="thumb_rate" id="thumb_up" data-id="115" />        </div>    </span>    <p class="rating">0</p> <!--to this...--></div>

This was just one of the things I tried. It appeared to select the right tag, but then it failed at fetching the inner value.

$(this).parent('#hand_rate').parent('.c_time').next('.rating').val(); //"this" is one of the img tags

Link to comment
Share on other sites

I go through DOM so methodically, but somehow it still is smarter than me. I am trying to access the innerHTML value of the p.rating tag.
<div class="c_name">MyName    <span class='c_time'> on October 19, 2010 06:49 PM        <div id="hand_rate">            <img src="/PNG/down.png" class="thumb_rate" id="thumb_down" data-id="115" /> <!--from either of these img tags-->            <img src="/PNG/up.png" class="thumb_rate" id="thumb_up" data-id="115" />        </div>    </span>    <p class="rating">0</p> <!--to this...--></div>

This was just one of the things I tried. It appeared to select the right tag, but then it failed at fetching the inner value.

$(this).parent('#hand_rate').parent('.c_time').next('.rating').val(); //"this" is one of the img tags

To my understanding that should select properly, but I'm pretty sure you're supposed to use the ".html()" function for innerHTML. ".val()" is only for a form controls current value.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...