2013-07-31 49 views
2

我的代碼是這樣的串聯在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 + \">"); 

但是,沒有正確串接請幫我

回答

2

當你寫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 + '">'); 
+0

雙引號丟失,請檢查您的答案 –

+0

@RavendraKumar固定 –

1

請嘗試下面的代碼。

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); 
1

進行連結在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 + "\">"); 
+0

也雙引號缺少 –

+0

看到我的更新答案.. .......... –

0
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);