1

我有event_wrapper可以通过单击中的链接在页面上动态添加的 div add-event。用户可以根据需要多次删除/添加这些 div。如果用户选择删除所有这些event_wrapperdiv,我想更改add-event. 这是HTML:

<div class="event_wrapper">
    <div class="event">
        <div class="well darkblue-background pull-left">
            <a class="close tooltip" data-tooltip="Delete this event"><i class="icon-remove"></i></a>
        </div>
    </div>
</div>


<div class="add-event pull-left">
    <a href="javascript:void(0);"> And Then...</a>
   </div>

(我正在使用 jQuery)我尝试使用:empty选择器,但它似乎不起作用。有什么建议么?谢谢!

4

3 回答 3

1

看看 - https://stackoverflow.com/a/3234646/295852

然后contentChange()像这样使用:

$('.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');
    }
});
于 2013-02-06T16:40:27.323 回答
0
if(!$(".event_wrapper")){
    $(".add-event pull-left").html("Whatever text you want here"); //changes the text of the div
     //or
    $(".add-event pull-left").children('a').html("whatever text you want here"); //changes the text of the anchor child
}
于 2013-02-06T16:32:44.653 回答
0
  if($(".event-wrapper").html() == null) {//looking inside event-wrapper; if it contains any thing
    $(".add-event a").html("whatever");
  }
于 2013-02-06T16:40:01.490 回答