Javascript 使用函数添加到div
下面是这个函数,我需要将它的结果附加到一个名为test的div中。我怎么做Javascript 使用函数添加到div,javascript,html,Javascript,Html,下面是这个函数,我需要将它的结果附加到一个名为test的div中。我怎么做 function(response) { alert('Your name is ' + response[0].name); } 我猜你有这样的想法: <div id="test"></div> 为了附加数据,而不仅仅是写下数据,您需要使用 function(response) { //Get current HTML in div current = documen
function(response) {
alert('Your name is ' + response[0].name);
}
我猜你有这样的想法:
<div id="test"></div>
为了附加数据,而不仅仅是写下数据,您需要使用
function(response) {
//Get current HTML in div
current = document.getElementById('test').innerHTML;
//Add your code to the current HTML. You may want a <br /> in there.
document.getElementById('test').innerHTML = current + 'Your name is ' + response[0].name;
}
这就像一个魅力:每个人都是正确的:谢谢大家,谢谢:嘿,抱歉再次打扰你。。。我修改了我的函数,我现在有这个函数,我是不是做错了什么?FB.api{method:'fql.query',query:'SELECT uid,name,pic_square FROM user WHERE uid=me或uid2 FROM friend WHERE uid1=me'},functionresponse{fori=0;i
function(response) {
//Get current HTML in div
current = document.getElementById('test').innerHTML;
//Add your code to the current HTML. You may want a <br /> in there.
document.getElementById('test').innerHTML = current + 'Your name is ' + response[0].name;
}
document.getElementById('test').innerHTML += 'Your name is ' + response[0].name;