Reputation: 15274
I'm trying to get spans text by passing the value of span id to the function like this :
function getDetails(testDetailId){
alert(jq("#"+testDetailId).text());
}
And I always get null alerted when the click is invoked :
jq("table tr").click(function(){
var testDetailId = jq(this).attr("id");
getDetails(testDetailId);
});
I use jquery no conflict :
var jq = jQuery.noConflict();
some html :
<span id="2">[{"testId":22,"testPerfReports":[]}]</span>
Any ideas ?
Upvotes: 0
Views: 4507
Reputation: 816272
It appears to me that both, the tr
element and the span
have the same ID.
That could be the problem, IDs have to be unique.
Upvotes: 1
Reputation: 5402
That is because you are capturing the click event of the <TR>
. As they are part of a table they do not have the text()
function. If you are trying to get the text of the span try doing the following:
jq("table tr").click(function(){
var concatenatedValues = $.map($('jq(this).find('span').text(), function (text) {
return option.value;
}).join(',');
alert(concatenatedValues);
});
Upvotes: 0