私のiPhoneWebアプリには、空白の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を使用して要素を動的に作成しますか、それとも要素を作成して、必要なセクションを表示するためにいつでも再表示しますか?
コードスニペット:
title=$(document.createElement('div'));
title.addClass('title');
title.html('Mango Fitness');
container.append(title);