jquery-attrs

Select attributes from jquery collections.

Usage no npm install needed!

<script type="module">
  import jqueryAttrs from 'https://cdn.skypack.dev/jquery-attrs';
</script>

README

$.fn.attrs()

Retrieves all the attributes with their associated values as object.

Example

<div id="elem" data-one="hello" data-two="world" something="else"></div>
$("#elem").attrs()
// -> { 'data-one': "hello", 'data-two': "world", 'something': "else" }

$("#elem").attrs(/^data\-/)
// -> { 'data-one': "hello", 'data-two': "world" }