I am trying to get value of td using jquery like this.
$("#id").find(".class").attr('value');
//or
$("#id").find(".class").val();
both returns empty string although it has a value. note* i'm trying get value of dynamically created element. thanks in advance.
Just write
$("#id .class").text();
Or to get the HTML use,
$("#id .class").html();
The val() function is primarily used to get the values of form elements such as input, select and textarea. You need text() or html() function to get the contents of td.
To get text
textOfTd = $("#id").find(".class").text();
To get Html
textOfTd = $("#id").find(".class").html();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With