我有以下数据:
label,callback,max-result,style
如何在script标签中插入每个项目?结果应该是:
<div class='**STYLE**'><script src='/feeds/posts/summary/-/**LABEL**?alt=json-in-script&callback=**CALLBACK**&max-results=**MAX-RESULT**' type='text/javascript'/></div>
感谢您的帮助!
答案 0 :(得分:1)
<div id='data_here'>
</div>
<script type='text/javascript'>
var data="label,callback,max-result,style".split(",");
var d = document.getElementById('data_here');
d.className = data[3];
var script = document.createElement('script');
script['src']="/feeds/posts/summary/-/"+data[0]+"?alt=json-in-script&callback="+data[1]+"&max-results="+data[2];
d.appendChild(script);
</script>