正如你所看到的,我有不止一個data-record-*
屬性,並且我想通過jQuery的幫助獲得這些屬性在每個函數中使用的值。如何獲取屬性值?
但我想用jquery自動獲取這些值,例如屬性以``data-record`開頭。
,我將發佈與jQuery/AJAX這些值
$('a').on('click',function(){
var el = $(this).data();
el.each(function(e){
alert(el);
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#" data-record-id="1" data-record-name="section-1" data-record-order="short" class="ajax">Click on me!</a>
我很困惑你問一點點:S – ThisGuyHasTwoThumbs
我有我的錨鏈接屬性我想要獲得每個函數的這個屬性的值:) –
似乎你需要一個過濾的屬性列表。檢查[this](https://stackoverflow.com/questions/4187032/get-list-of-data-attributes-using-javascript-jquery) –