Hide-show like dislike jquery script for each block -
i have many similar blocks , dislike divs:
<div class="cal_days com_each_photo"> <img class="littleimage" src="img/calendar/calendar_2.jpg" alt="day"> <div class="com_blur"> <div class="com_link_like" style="cursor:pointer">like!</div> <div class="com_link_dislike" style="cursor:pointer;display:none">dislike</div> </div>
<div class="cal_days com_each_photo"> <img class="littleimage" src="img/calendar/calendar_2.jpg" alt="day"> <div class="com_blur"> <div class="com_link_like" style="cursor:pointer">like!</div> <div class="com_link_dislike" style="cursor:pointer;display:none">dislike</div> </div>
... made jquery script:
$(document).ready(function(){ $(".com_link_like").click(function () { $(this).hide(); $('.com_link_dislike').show(); $('.com_link_dislike').click(function () { $(this).hide(); $('.com_link_like').show(); }) }) });
problem: works, when push "like" divs changed class ".com_link_dislike" ".com_link_dislike" need change in exact block. how can fixed?
if want change associated like/dislike, traverse tree.
$(this).parent().find('.com_link_like').show();
will go parent dom, find proper div, , show it.
Comments
Post a Comment