Javascript Jquery中的修剪
每当我在网格视图中单击“编辑”按钮时,特定的行数据应该显示在文本框中。但是在这里,我在文本框中得到了不必要的空格。 如何修剪文本框(txtName)中的空格??文本中有空格。尝试使用 使用javascript的Javascript Jquery中的修剪,javascript,jquery,Javascript,Jquery,每当我在网格视图中单击“编辑”按钮时,特定的行数据应该显示在文本框中。但是在这里,我在文本框中得到了不必要的空格。 如何修剪文本框(txtName)中的空格??文本中有空格。尝试使用 使用javascript的trim()函数 对于jquery,请看这里 看看这里 范例 $("#txtName").val($.trim($(this).text())); 使用javascripttrim()方法 var str = " lots of spaces before and af
trim()
函数
对于jquery,请看这里
看看这里
范例
$("#txtName").val($.trim($(this).text()));
使用javascripttrim()
方法
var str = " lots of spaces before and after ";
$( "#original" ).html( "Original String: '" + str + "'" );
$( "#trimmed" ).html( "$.trim()'ed: '" + $.trim(str) + "'" );
你搜索过“修剪javascript”吗?
var str = " lots of spaces before and after ";
$( "#original" ).html( "Original String: '" + str + "'" );
$( "#trimmed" ).html( "$.trim()'ed: '" + $.trim(str) + "'" );
$("#txtName").val($(this).text().trim());
function ShowEditBox(serial)
{
$("#divEditBox").slideDown("medium");
var pserial ='PName'+ serial;
var colindex = 0;
var $tr = $("#" + pserial).parent().parent();
$tr.find('td').each(function () {
if (colindex == 2) {
$("#txtName").val($.trim($(this).text()));
} else if (colindex == 3) {
$("#txtSurName").val($.trim($(this).text()));
} else if (colindex == 4) {
$("#txtEmail").val($.trim($(this).text()));
} else if (colindex == 5) {
$("#txtMobile").val($.trim($(this).text()));
} else if (colindex == 6) {
$("#txtAddress").val($.trim($(this).text()));
}
colindex++;
})
$("#hdField").val(serial);
}