【发布时间】:2012-05-25 14:35:34
【问题描述】:
在我的 iPhone webapp 中,我有一个空白的 div,我动态地向它添加东西 使用:
var example=$(document.createElement('which-ever-tag i need'));
example.html('blah blah')
blank_div.append(example);
这样我可以根据需要添加和删除元素。
example.remove();
我最近想,我也可以从我最初的 HTML 页面中这样做:
<div id='homepage'>
place some content in here
</div>
<div id='second_page'>
some more content
</div>
然后我可以隐藏和取消隐藏某些部分。我只是想知道最好的方法是什么?
JavaScript 是动态创建元素,还是制作它们并在需要显示部分时取消隐藏?
代码sn-p:
title=$(document.createElement('div'));
title.addClass('title');
title.html('Mango Fitness');
container.append(title);
【问题讨论】:
标签: javascript iphone performance web-applications dynamic