HTML data and a string that looks like a number

前端 未结 3 1306
梦如初夏
梦如初夏 2021-01-19 04:48

For this html

this js:

console.log($(\'div\').data(\'a\'));

retur

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-19 05:42

    You can bypass data() and grab the attribute directly:

    console.log($('div').attr('data-a'));
    

    Demo

提交回复
热议问题