Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery连接变量和字符串_Jquery - Fatal编程技术网

jquery连接变量和字符串

jquery连接变量和字符串,jquery,Jquery,我需要用jquery连接一个带字符串的变量 这是我的示例代码: $("#totriepilogoassegni").html(msg); 味精后,我需要插入欧元或€ 你怎么能修好它 致意 Andrea您可以使用concatenation+运算符将字符串转换为变量 $("#totriepilogoassegni").html(msg + ' euro'); $("#totriepilogoassegni").html(msg + ' €'); 使用Append 您可以创建一个js方法来重用

我需要用jquery连接一个带字符串的变量 这是我的示例代码:

 $("#totriepilogoassegni").html(msg);
味精后,我需要插入欧元或€

你怎么能修好它

致意 Andrea

您可以使用concatenation+运算符将字符串转换为变量

$("#totriepilogoassegni").html(msg + ' euro');

$("#totriepilogoassegni").html(msg + ' €');
使用Append


您可以创建一个js方法来重用它:

function currencyAppender(msg, curr){
    return msg +' '+curr;
}
然后您可以这样使用它:

$("#totriepilogoassegni").html(currencyAppender(msg, 'euro'));

这样,您可以将其用于多种货币。

这可能是正确的,也可能是不正确的,这取决于msg本身的类型is@AmmarCSEmsg将是文本,我想正是,你认为:@ammarces Check UPdated Answernice one;。就像创意一样什么类型的味精?它是如何计算的?
$("#totriepilogoassegni").html(currencyAppender(msg, 'euro'));