JSPM

query-by-attribute

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q34439F
  • License ISC

query selector by attribute name and value

Package Exports

  • query-by-attribute
  • query-by-attribute/query-by-attribute.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (query-by-attribute) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

query-by-attribute

query selector by attribute name and value

Install

npm install query-by-attribute

Usage & Api

var query_by_attribute = require("query-by-attribute");

_ele('divResult3').innerHTML = "<span myattr=11>aaa</span> <span myattr=22>bbb</span> " +
    "<b myattr=22>ccc</b> <b myattr=22>ddd</b> <b id='sp-char'>eee</b>";

var val = "[]:<>'\"\\/  \t 	 ";
_ele('sp-char').setAttribute('myattr', val);

//query_by_attribute(el, head, attrName, attrValue, tail, all)
return query_by_attribute('divResult3', '', 'myattr').getAttribute('myattr') === '11' &&
    query_by_attribute('divResult3', '', 'myattr', '22').textContent === 'bbb' &&
    query_by_attribute('divResult3', 'b', 'myattr', '22').textContent === 'ccc' &&
    query_by_attribute('divResult3', 'b', 'myattr', '22', ':nth-of-type(2)').textContent === 'ddd' &&
    query_by_attribute('divResult3', '', 'myattr', val).textContent === 'eee';
;