kumar
kumar

Reputation: 2944

What is the differnce between these two types using jquery

$('tr td:first-child').click(function() {
            var foobar = $(this).text();
            $("#showgrid").load('/Product/List/Item?id=' + foobar);
        });

When I am sending foobar value like this in the Actionresult method I am getting string id value perfectly but I am not able to display the grid?

But interesting thing is when I am sending like this

 $("#showgrid").load('/Product/List/Item?id=' + "12345");

Then I am able to display the grid. foobar result is same 12345.

What is the different between these two types?

Upvotes: 0

Views: 58

Answers (2)

David Murdoch
David Murdoch

Reputation: 89332

Try this:

var foobar = $.trim($(this).text());

You may have some extra spaces in there.

Upvotes: 1

typeoneerror
typeoneerror

Reputation: 56968

From the docs: text() returns the combined text contents of each element in the set of matched elements, including their descendants. So, if you have any other nodes that contain text in the first-child of the td, it'll include that text as well. Can you post some markup so we can see what you are targeting?

Upvotes: 1

Related Questions