javascript
1function(sample) { 2 console.log(sample.title) 3 };
上記のコードでconsole.logにはfooが表示されます
このfooをconsole.logではなくhtmlに挿入したいのですがどのようにすればよいのでしょうか
私は次のプログラムを考えたのですが何も表示されませんでした
HTML
1<html> 2 <head> 3 <script> 4 $(document).ready(function() { 5 function(sample) { 6 $('t').text(sample.title) 7 }; 8 }); 9 </script> 10 11 </head> 12 <body> 13 <p> 14 <span id="t"></span> 15 </p> 16 </body> 17</html>
sampleのデータ構造は下記のようになっています
{title: "foo", id: 1, created_at: "2010/10/10 10:10:10 +0000"}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2015/10/18 02:38