18 decemb...">

Get data from datetime element

I want to highlight the date from the datetimeitem below.

<time datetime="2015-12-18T12:38" pubdate> 18 december 12:38</time>

How can I do this, i.e. to get 2015-12-18T12:38?

I know I can extract the text "18 december 12:38". But now this is what I want.

Regards

+4
source share
2 answers

If you want to get the attribute value of this element:

document.getElementsByTagName("time")[0].getAttribute("datetime");
+3
source

You can do it with jquery .attr()- http://api.jquery.com/attr/

$('time').attr('datetime')
+1
source

Source: https://habr.com/ru/post/1620744/


All Articles