📜  element data-id - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:22.947000             🧑  作者: Mango

代码示例2
// Here's our buttonvar button = document.getElementById('your-button-id'); // Get the valuesvar cmd = button.getAttribute('data-cmd');var id = button.getAttribute('data-id'); // Change the valuesbutton.setAttribute('data-cmd', yourNewCmd);button.setAttribute('data-id', yourNewId);