こんちには。 職人見習いの木村です。 jQueryの公式プラグインはいくつかありますが、今回は、テンプレートエンジンである「jQuery Templates」の使い方をご紹介します。 まずは、jQueryとjQuery Templatesを読み込みます。 次に、HTMLに以下のように、テンプレートを差し込む場所と、テンプレート自体を記述していきます。 そして、そのテンプレートに渡す値をJSの方で指定していきます。 $.getJSON('hoge.json', function(data) { $('#item').tmpl(data).appendTo('#container'); //id='container'にテンプレートid='item'を挿入する。 } JSON等などでAjax通信を必要とするアプリケーションを制作するときに、使えます。 ※この記事は、なかの人(moresmile
