Can you set multiple attributes with the DOM's setAttribute function?

后端 未结 5 1217
暗喜
暗喜 2021-01-06 16:09

Let\'s say I wanted to create an input element using the DOM. Instead of doing something like this

var input = document.createElement(\"input\");
input.setAt         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-06 16:41

    Yes, You can do using Jquery.

    $(input).attr(
    {
      "data-test-1": num1, 
      "data-test-2": num2
    });
    

提交回复
热议问题