javascript - Changing text when unrelated divs are empty -
i have div event_wrapper
can dynamically added on page clicking link in add-event
. user can delete/add these divs many times want. if user chooses delete of these event_wrapper
divs, want alter text within add-event
. here html:
<div class="event_wrapper"> <div class="event"> <div class="well darkblue-background pull-left"> <a class="close tooltip" data-tooltip="delete event"><i class="icon-remove"></i></a> </div> </div> </div> <div class="add-event pull-left"> <a href="javascript:void(0);"> , then...</a> </div>
(i using jquery) tried using :empty
selector, not seem working. suggestions? thanks!
have @ - http://stackoverflow.com/a/3234646/295852
and utilize contentchange()
like:
$('.event-wrapper').contentchange(function(){ if($(this).children().length > 0){ // events exist $(".add-event pull-left").children('a').html('and then...'); } else { // no events $(".add-event pull-left").children('a').html('your text'); } });
javascript jquery jquery-selectors
No comments:
Post a Comment