Fmdpa Posted November 23, 2010 Share Posted November 23, 2010 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 More sharing options...
Dilated Posted November 23, 2010 Share Posted November 23, 2010 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 More sharing options...
Fmdpa Posted November 23, 2010 Author Share Posted November 23, 2010 Oops. Thanks, that isn't the first time I've done that. Link to comment Share on other sites More sharing options...
skaterdav85 Posted November 23, 2010 Share Posted November 23, 2010 you could probably shorten your chaining which might be more optimized by using the parents() method and the children() methodSo maybe something like this: $(this).parents('.c_time').children('.rating').html(); Link to comment Share on other sites More sharing options...
Fmdpa Posted November 23, 2010 Author Share Posted November 23, 2010 That's actually how I ended up doing it once I figured out my problem. Thanks anyway! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.