fetch a attribute form Next & Prev div using Jquery -


i'm trying out example learn how fetch attribute "href" of "a tag" next & prev div's. consider click on 'a tag' in div id="rw2", need href of tag in prev div#rw1 , next div#rw3.

  <div class="plist" id="rw1">     <div class="image">          <a href="1.html">1</a>     </div>     <div class="some"></div>     <div class="few"></div>   </div>    <div class="plist" id="rw2">     <div class="image">          <a href="2.html">2</a>     </div>     <div class="some"></div>     <div class="few"></div>   </div>     <div class="plist" id="rw3">     <div class="image">          <a href="3.html">3</a>     </div>     <div class="some"></div>     <div class="few"></div>   </div>     ...... 

expect result when

#rw1 .image clicked - next = '2.html' & prev = ''  #rw2 .image clicked - next = '3.html' & prev = '1.html' 

try:

$(".plist .image a").click(function() {     var p = $(this).closest(".plist").prev(".plist").find("a").prop("href");     var n = $(this).closest(".plist").next(".plist").find("a").prop("href"); }); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -