php - Jquery Selector for dynamically created elements -


i creating html in php here

<?php while(){   ?>  <a  id="click_to_expand-1" class="btn btn-default btn-sm "> more</a>  <div id="expand_content-1" class="row extra-detail-gist" style="display: none;">       <ul class="extra-feature-gist">           <li>            <p><strong>baths :</strong><span class="text-success"> <?php echo $rw["baths"]; ?></span></p>           </li>       </ul> <?php } ?> 

here jquery code

$(function(){         $('.row.extra-detail-gist').css('display','none');         $('.btn.btn-default.btn-sm').click(function(){             $('.row.extra-detail-gist').slidetoggle('slow');             $(this).toggleclass('slidesign');             return false;         });     }); 

this code apply div created , divs showing @ click.how can differenciate each click on 'more'?

updated: code working first 1 properly..but rest of records not working

$(function(){         $('#expand_content-1').css('display','none');         $('#click_to_expand-1').click(function(){             $('#expand_content-1').slidetoggle('slow');             $(this).toggleclass('slidesign');             return false;         }); }); 

here jsfiddle

try this:

working example

$(document).on('click','.btn.btn-default.btn-sm',function(){     $(this).parent().next('.row.extra-detail-gist').slidetoggle('slow');     $(this).toggleclass('slidesign');     return false; }); 

with line $('.row.extra-detail-gist') selecting divs has row extra-detail-gist class.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -