我的代碼是這樣的串聯在JavaScript
var call_from='fb_test'
jQuery('.test').html("<img src=\"https://wwww.socialappshq.com/images/socialapps/loading.gif\" height=\"15\" width=\"15\" id=\"loading_image_\" + call_from + \">");
但是,沒有正確串接請幫我
我的代碼是這樣的串聯在JavaScript
var call_from='fb_test'
jQuery('.test').html("<img src=\"https://wwww.socialappshq.com/images/socialapps/loading.gif\" height=\"15\" width=\"15\" id=\"loading_image_\" + call_from + \">");
但是,沒有正確串接請幫我
當你寫HTML使用JavaScript,喜歡'
包圍字符串和"
附上屬性值
var call_from='fb_test'
jQuery('.test').html('<img src="https://wwww.socialappshq.com/images/socialapps/loading.gif" height="15" width="15" id="loading_image_' + call_from + '">');
請嘗試下面的代碼。
var call_from='fb_test';
var yourHtml = '<img src="https://wwww.socialappshq.com/images/socialapps/loading.gif" height="15" width="15" id="loading_image_' + call_from + '"/>';
jQuery('.test').html(yourHtml);
進行連結在JavaScript
試試這個
var call_from='fb_test'
jQuery('.test').html("<img src=\"https://wwww.socialappshq.com/images/socialapps/loading.gif\" height=\"15\" width=\"15\" id=\"loading_image_\"" + call_from + "\">");
也雙引號缺少 –
看到我的更新答案.. .......... –
var yourHtml = '<img src="https://wwww.socialappshq.com/images/socialapps/loading.gif" height="15" width="15" id="loading_image_' + call_from + '"/>';
jQuery('.'+call_from).html(yourHtml);
雙引號丟失,請檢查您的答案 –
@RavendraKumar固定 –