jQueryを使用して最初の子要素のデータ属性を取得します
-
21-12-2019 - |
質問
最初のLIのデータ属性をULに入ろうとしています。の線に沿ったもの...
var theTimeline = document.getElementById("the_timeline");
var timeline_items = $(theTimeline).filter('li');
var first_date = timline_items.lastChild.getAttribute("data-pubdate");
var last_date = timline_items.lastChild.getAttribute("data-pubdate");
.
誰かが私にShove Intを正しい方向に与えるのに十分な人はありますか?
解決
最初:
$("#the_timeline li").first().data("pubdate");
.
Last:
$("#the_timeline li:last").data("pubdate");
. 他のヒント
jQuery 、あなたはできる:
$('#the_timeline > li').first().data("pubdate");
.
と:
$('#the_timeline > li:last').data("pubdate");
. 所属していません StackOverflow