jQuery方式

// 获取
$('#test').attr('mydata');
// 设置
$('#test').attr('mydata','data-content');
// 移除
$('#test').removeAttr('mydata');

 JS方式

// 获取
document.getElementById('test').getAttribute('mydata');
//设置
document.getElementById('test').setAttribute('mydata','data-content');

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
猜你喜欢
  • 2022-02-24
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案