jQuery: Add multiple attributes to DOM element

How to add attribute to DOM in jQuery?

You need to create a DOM element, and add more attributes to it using jQuery. Sometimes you finished with JavaScript code, what looks like this:

I was curious if it is possible to make it a nicer way. Good news is: yes, it is!

jQuery logo

How to add multiple attributes to DOM in jQuery?

To add multiple attributes to DOM element you have to just add it this way:

You will just insert all values as associative array, which has key and value pairs.

Please tell what you think