How to get an the text value of an element in jQuery?
I have an HTML table generated dynamically with field names generated for each row dynamically as well.
Here is the structure I have within the table. I have a <td>
tag and within it I have a <span>
tag. I want to get the value for each tag. I have tried this this way:
$("#txtname").attr('value',$("#table1").find('td > #selname_'+i).text());
In the above code 开发者_开发知识库I am setting the $("#txtname")
(textbox value) with the value from the <span>
tag (selname). Here i
is an incrementing value.
I want to get the text, but do not get the <span>
value, and I am not able to assign to it.
No need to make your selectors so complicated:
$("#txtname").val($("#selname_"+i).text());
精彩评论