-1
我想從列表中的鏈接中獲取數據屬性,當我點擊它時。從ul列表中的鏈接獲取數據屬性
$(document).on('click', "ul.pagination li a", function(e)
{
e.preventDefault();
var page = $(this).attr("page");
var article_id = getUrlParameter('aid');
alert(page);
$('.comments').load('page', {'type':'reload', 'article_id':article_id, 'page':page}, function() {
$('.comments').scrollMinimal();
$('.comments').highlight();
});
});
名單應該是這樣的:
<div class="fnone">
<ul class="pagination">
<li><a data-page="2" href="testpage=2#comments">2</a></li>
我的問題是, 「頁」 總是undefined
。不完全確定我在這裏出錯的地方。
使用'$(本).attr( 「數據頁」);' – guradio
的document.getElementById (ID).getAttribute( 「數據」); – Rigidity