Skip to content

Instantly share code, notes, and snippets.

@ayuLiao
Last active June 8, 2018 08:26
Show Gist options
  • Save ayuLiao/9239228af1b2c90e4b5951413e9e8d02 to your computer and use it in GitHub Desktop.
Save ayuLiao/9239228af1b2c90e4b5951413e9e8d02 to your computer and use it in GitHub Desktop.
判断div中子元素数量是否超过8,超过,不能再动态添加 没有超过,则在改div中添加新的子元素
<div class="gameroomall">
<div class="gameroomayu">
</div>
</div>
function onAdd(){
var configTable = $('.gameroomall');
var num = parseInt(configTable.find('.gameroomayu').length);
if (num == 8){
//信息框,使用了layer插件,google搜layer.js导入layer.js和layer.css则可使用
layer.open({
content : '最多只允许创建8条规则'
,btn : '关闭'
});
}else{
str ="<h2>123</h2>";
//添加到子节点
configTable.append(str);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment