我在一个小问题上卡住了。
我想使用JavaScript设置输入框的值,但是jQuery没有显示完整的句子。
var name = "Richard Keep";
但是当我尝试这样做时
$('input#nameid').val(name)
转换为这个输入
<input type="text" id="nameid">
值被设置为仅限于 Richard,而不是 Richard Keep。如何使jQuery回显整个字符串而不仅仅是字符串中的第一个单词?谢谢。
编辑:
<td id="To_be_collected_port" onclick="requestPopup()" class="tr-selected">
<div class="pop-td To_be_collected_port">
</div>
this is the content am fetching
</td>
这将仅显示此文本。
var str = $('#To_be_collected_port').text();
然后。
$('.xyz').html("<input type=\"text\" name=\"text\" id=\"selected-service-text\" value="+str+">");
maxlength
属性吗?展示你全部的代码可能有助于缩小问题范围。 - Rory McCrossanname
实际上是Richard
,要么其他东西在干扰。 - dfsq