10 examples of 'jquery filter by data attribute' in JavaScript

Every line of 'jquery filter by data attribute' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
8function filterData (data, prop, value){
9 var filtered = _.filter(data, function(n){
10 return n[prop] == value;
11 });
12 return filtered;
13};
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

93function _filter(dataset, ...filters) {
94 return dataset.filter(d=>{
95 return filters.every(f=>{
96 return f(d)
97 })
98 })
99}
239function extractValue ($, attribute) {
240 if ($ && $.length) {
241 return $.attr(attribute) || undefined
242 }
243 return undefined
244}
44function dataAttr( el, attr ) {
45 var data = el.getAttribute( 'data-' + attr );
46
47 try { // JSON.parse可能报错
48
49 // 当data===null表示,没有此属性
50 data = data === null ? undefined : data === 'true' ? true :
51 data === 'false' ? false : data === 'null' ? null :
52
53 // 如果是数字类型,则将字符串类型转成数字类型
54 +data + '' === data ? +data :
55 /(?:\{[\s\S]*\}|\[[\s\S]*\])$/.test( data ) ?
56 JSON.parse( data ) : data;
57 } catch ( ex ) {
58 data = undefined;
59 }
60
61 return data;
62}
87function filter(_) {
88 var ft = _.ft,
89 fn = function(t) { return t.data < ft; };
90 return (fn.fields = ['data'], fn);
91}
1160filter(value, field, matchMode) {
1161 if(!this.isFilterBlank(value))
1162 this.filters[field] = {value: value, matchMode: matchMode};
1163 else if(this.filters[field])
1164 delete this.filters[field];
1165
1166 if(this.lazy) {
1167 this.stopFilterPropagation = true;
1168 }
1169
1170 this._filter();
1171}
117public filterData(data, filters: Filter[]) {
118 let d = data.slice();
119
120 filters.forEach((filter) => {
121 d = filter.parseData(d);
122 });
123
124 return d;
125}
59value: function applyFilters(attribute, value) {
60 var filters = _Interweave2.default.getFilters(attribute);
61 var newValue = value;
62
63 if (!filters.length) {
64 return newValue;
65 }
66
67 filters.forEach(function (_ref) {
68 var filter = _ref.filter;
69
70 newValue = filter.filter(newValue);
71 });
72
73 return newValue;
74}
195function data(el, prop, value) {
196 var prefix = 'data';
197 var elData = el[prefix] || {};
198 if (typeof value === 'undefined') {
199 if (el[prefix] && el[prefix][prop]) {
200 return el[prefix][prop];
201 } else {
202 var dataAttr = el.getAttribute(prefix + '-' + prop);
203 if (typeof dataAttr !== 'undefined') {
204 return dataAttr;
205 }
206 return null;
207 }
208 } else {
209 elData[prop] = value;
210 el[prefix] = elData;
211 return el;
212 }
213}
275function getDataAttribute( element, attribute ) {
276 if ( supportsDataset ) {
277 return element.dataset[attribute];
278 }
279 else {
280 return element.getAttribute( 'data-' + attribute );
281 }
282}

Related snippets