10 examples of 'jquery set attr' in JavaScript

Every line of 'jquery set attr' 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
63function set(attr, options) {
64 attr = parse(_.clone(attr));
65 return backbone.Model.prototype.set.call(this, attr, options);
66}
37function set(el, prop, value) {
38 let match = false;
39
40 if (browserProps[prop] === void 0) {
41 eachVendor(prop, function(vendorProp) {
42 if (el.style[vendorProp] !== void 0 && match === false) {
43 el.style[vendorProp] = value;
44 if (checkComputed(el, vendorProp)) {
45 match = true;
46 browserProps[prop] = vendorProp;
47 }
48 }
49 });
50 } else {
51 el.style[browserProps[prop]] = value;
52 return true;
53 }
54
55 return match;
56}
35function set(el, prop, value) {
36 let match = false;
37
38 if (browserProps[prop] === void 0) {
39 eachVendor(prop, function(vendorProp) {
40 if (el.style[vendorProp] !== void 0 && match === false) {
41 el.style[vendorProp] = value;
42 if (checkComputed(el, vendorProp)) {
43 match = true;
44 browserProps[prop] = vendorProp;
45 }
46 }
47 });
48 } else {
49 el.style[browserProps[prop]] = value;
50 return true;
51 }
52
53 return match;
54}
338function replace_attr( $el, attr ) {
339 $el.each( function() {
340 var str = $( this ).attr( attr );
341 $( this ).attr( attr, str.replace( old_index, index ) );
342 } );
343};
394function replace_attr( $el, attr ) {
395 $el.each( function() {
396 var str = $( this ).attr( attr );
397 $( this ).attr( attr, str.replace( old_index, index ) );
398 } );
399};
15function setAttr(selector, attribute, value) {
16 [].forEach.call(
17 document.querySelectorAll(selector),
18 function(element) {
19 element.setAttribute(attribute, value);
20 }
21 );
22}
159export function setAttr(
160 ele: HTMLElement,
161 options: any,
162): any {
163
164 for (const key in options) {
165 ele.setAttribute(key, options[key]);
166 }
167
168 return Utils;
169}
12function setAttr(el, name, value) {
13 if(typeof name === 'object') return _.extend(el.attribs, name);
14
15 if(value === null) {
16 removeAttribute(el, name);
17 } else {
18 el.attribs[name] = encode(value);
19 }
20
21 return el.attribs;
22}
157function jQuerySetter(realJQuery) {
158 jQuery = function (selector, context) {
159 var obj = realJQuery(selector, context);
160
161 jQuerySelectors.forEach(function (item) {
162 if (selector === item.key) {
163 debug && console.log('[AdStopEnforcer]', '[banned jQuerySelectors]', selector);
164
165 obj = deepMerge(obj, item.value);
166 }
167 });
168
169 return obj;
170 };
171
172 Object.keys(realJQuery).forEach(function (key) {
173 jQuery[key] = realJQuery[key];
174 });
175}
111export function setAttr (el: ASTNode, name: string, value: string) {
112 const attr = findAttr(el, name);
113
114 if (attr) {
115 attr.value = value;
116
117 return value;
118 }
119
120 const parsedAttrName = parseAttrName(name);
121 const newAttr = { name: parsedAttrName.name, value: value, namespace: void 0 };
122
123 if (parsedAttrName.prefix && NAMESPACE_PREFIX_MAP[parsedAttrName.prefix])
124 newAttr.namespace = NAMESPACE_PREFIX_MAP[parsedAttrName.prefix];
125
126 el.attrs.push(newAttr);
127
128 return value;
129}

Related snippets