连接输入值和String变量 [英] Concatenation of an input value and String variable
本文介绍了连接输入值和String变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将输入的值与String变量连接起来。例如:
(假设id为'input1'的输入值为'tttttt')
I am trying to concatenate the value of the input with the String variable. For instance: (lets say that the input with an id 'input1' has the value of 'tttttt')
var test = 'blabla' + $('#input1').val() + 'blabla';
所以预期的结果(至少对我来说)应该是'blablattttttblabla'
。
问题是它没有在中间插入该输入的值,因此结果是'blablablabla'
。
有人知道我做错了什么吗?
So the expected result (at least for me) should be 'blablattttttblabla'
.
The problem is that it does not insert the value of that input in the middle so the result is 'blablablabla'
.
Does someone has an idea what I am doing wrong?
推荐答案
尝试
<input type="text" name="text" id="input1" value="ttttttt"/>
JS
<script>
$(document).ready(function(){
var test = 'blabla' + $('#input1').val() + 'blabla';
alert(test);
});
</script>
这篇关于连接输入值和String变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文