如何在Javascript中赋值期间附加字符串值? [英] How to append a string value during assignment in Javascript?
本文介绍了如何在Javascript中赋值期间附加字符串值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,我不知道这是否可行,但我想通过参考在js中设置一个给定变量。
Hey i dont know if that is possible but i want to set a given variable in js by reference.
我想要什么是的,每次我将一个字符串传递给函数 addstring
时,文本字段的值被添加为 + =
What i want to do is, that each time i pass a string to the function addstring
that the value of the textfield is added like +=
function addstring(string)
{
document.getElementById("string").value = string; // its a textfield
}
我该怎么办?
推荐答案
+ =
工作正常。
var str = "stack";
str += "overflow";
console.log(str); //alert(str); Use firebug!!
stackoverflow
stackoverflow
这篇关于如何在Javascript中赋值期间附加字符串值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文