php - Jquery script only targeting first prepended element -


why following script targeting first element

jquery:

  $(document).ready(function () {       $(".edit_post_tab").click(function () {           var utility_id = $(this).attr("rel");           $(this).siblings("#post_utilities" + utility_id).toggle();       });   }); 

html/php:(the following receieved through page)

<div class="edit_post_tab" rel="'.$rand_id.'"></div> <div class="post_utilities" id="post_utilities'.$rand_id.'" style="display:none;">   <div class="post_utilities-arrow"></div>   <div class="post_utilities-window">       <div id="post_utility" class="tab1-post" rel="'.$rand_id.'">edit post</div>       <div id="post_utility" class="tab2-post" rel="'.$rand_id.'">delete post</div>   </div> </div> 

my question: problem face when post data , prepend it works fine when 2 prepended elements exist jquery selector targets first of twoprepended elements.when refresh page problem disappears


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -