Reputation: 152
I have search program where I have to find some text after click on that search result it should set into input box but it gives me some space before text
You can check it on below link:
$("tbody > tr").click(function(){
var proid = $(this).text().split(":"); $("#searchInput").val(proid[0]);
});
Upvotes: 1
Views: 76
Reputation: 3083
use jquery trim for this Reference API
Replace :
$("#searchInput").val(proid[0]);
To:
$("#searchInput").val(proid[0].trim());
You should trigger click event like
$("tbody > tr > td").click(function(){
var proid = $(this).text().split(":"); $("#searchInput").val(proid[0].trim());
});
Upvotes: 2
Reputation: 6154
Change $("tbody > tr")
to $("tbody td")
to select the table cell instead of the row.
Upvotes: 1
Reputation: 34107
Working demo http://api.jquery.com/jQuery.trim/
API:
.trim
: http://api.jquery.com/jQuery.trim/
code
$("tbody > tr").click(function(){
var proid = $(this).text().split(":");
alert(proid[0]);
$("#searchInput").val(proid[0].trim());
});
Upvotes: 4