将Javascript变量作为我使用的对象标记中的数据值
var one= "http://localhost:3000/?id=";
var two = one + fort + "&to=" + too;
$("#chatArea").html('<object data= +two />');
但它没有用。
如何将var交给我的数据属性?
答案 0 :(得分:2)
你需要使用字符串连接
$("#chatArea").html('<object data="'+ two + '"/>');
答案 1 :(得分:1)
您可以使用字符串连接:
$("#chatArea").html('<object data="' + two + '" />');
或者您可以使用$(html, attributes)
function,其中html字符串用于新元素,而对象具有新元素的属性:
$("#chatArea").html($('<object/>', { data: two }));