jQuery hide post based on UID -
i want hide div based on user id 1 click button.
<div class="click_me" id="<?php echo $uid; ?>">click me hide</div> <div class="post" id="post<?php echo $uid; ?>"> bla bla </div> <div class="post" id="post<?php echo $uid; ?>"> bla bla </div> <div class="post" id="post<?php echo $uid; ?>"> bla bla </div>
jquery
$(".click_me").click(function() { var id = $(this).attr("id"); $("#post"+id).hide(); }
when seek above code. hide 1 post not same uid.
so how can hide if uid same?
use classes command multiple elements, below code, or seek fiddle! fiddle uses 77 in place of php generated id demonstration purposes only
$(".click_me").on('click', function() { var id = $(this).attr("id"); $(".post"+id).hide(); });
and alter these to:
<div class="post<?php echo $uid; ?>"> bla bla </div> <div class="post<?php echo $uid; ?>"> bla bla </div> <div class="post<?php echo $uid; ?>"> bla bla </div>
jquery
No comments:
Post a Comment