-3

Hello I have this code in HTML :

<td id="t_startdate">2019-04-29 00:00</td>

And I would like to get 2019-04-29 00:00 using jquery I tried this :

var start = $('#t_startdate');

But when I try to show the variable start with :

alert(start);

I get undefined

Could you help me please ?

Thank you !

4 Answers4

0

try:

var start = jQuery('#t_startdate').text();
Prashant Patil
  • 2,463
  • 1
  • 15
  • 33
0

Use .text() method for accessing the text of the . like:

t_startdate = $('#t_startdate').text();
alert(t_startdate);

You can see this for clarification

0

You can get it like below:

$('#t_startdate').textContent
Jeet Kumar
  • 555
  • 3
  • 12
0

you have to wait because ur document is not ready! He said its undefined because its not loaded...

use:

       $(document).ready(function(){
           var start = jQuery('#t_startdate').text();
           alert(start);
       });
Michi
  • 129
  • 5