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');
}
}
精彩评论