Javascript 当不相关的div为空时更改文本

Javascript 当不相关的div为空时更改文本,javascript,jquery,jquery-selectors,Javascript,Jquery,Jquery Selectors,我有divevent\u包装器,可以通过单击addevent中的链接在页面上动态添加。用户可以根据需要多次删除/添加这些div。如果用户选择删除所有这些event\u包装div,我想更改addevent中的文本。以下是HTML: <div class="event_wrapper"> <div class="event"> <div class="well darkblue-background pull-left">

我有div
event\u包装器
,可以通过单击
addevent
中的链接在页面上动态添加。用户可以根据需要多次删除/添加这些div。如果用户选择删除所有这些
event\u包装
div,我想更改
addevent
中的文本。以下是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
选择器,但它似乎不起作用。有什么建议吗?谢谢

看看-

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
}
然后使用
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');
    }
});
看看-

然后使用
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');
    }
});

请给出一些代码示例。如果您想在addevent$(“.addevent”).children('a').html(“您的文本”)中更改文本;是否要检查事件包装器中是否有事件包装器div或div?请提供一些代码示例。如果您想在addevent$(“.addevent”).children('a').html(“您的文本”)中更改文本;是否要检查事件包装器中是否有事件包装器div或div?