开发者

Append a word between empty element

How can by jquery know that i开发者_运维百科f between a element is empty append between same element word "there is not"?

<div>Ok</div>
<div>No</div>
<div></div> // i want append between this div "there is not" that is empty. Like: <div>there is not</div>
<div>Hello</div>


Try -

$("div:empty").append("there is not");

Demo - http://jsfiddle.net/St8sV/


More verbose form:

$('div').each(function() {
   if ($(this).html() == '') {
      $(this).html('there is not');
   }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜