10 examples of 'jquery add attribute to input' in JavaScript

Every line of 'jquery add attribute to input' 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
217function AddVariableToInput(element_id, value) {
218
219 var input = document.getElementById (element_id);
220 var $input = jQuery(input);
221
222 if(document.selection) {
223 // Go the IE way
224 $input[0].focus();
225 document.selection.createRange().text=value;
226 }
227 else if('selectionStart' in input) {
228 var startPos = input.selectionStart;
229 input.value = input.value.substr(0, startPos) + value + input.value.substr(input.selectionEnd, input.value.length);
230 input.selectionStart = startPos + input.value.length;
231 input.selectionEnd = startPos + value.length;
232 } else {
233 //do nothing for now.
234 }
235}
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

22function addAttribute(attribute, value) {
23 var attributes = filterUrl.getQueryVar(attribute);
24 if (!attributes) {
25 attributes = value;
26 } else {
27 if (attributes.indexOf(value) == -1) {
28 attributes += ',' + value;
29 }
30 }
31 filterUrl = filterUrl.addQueryVar(attribute, attributes);
32 return filterUrl;
33}
504export function applyAttribute(element, name, value) {
505 if (booleanAttributes[name]) {
506 // Boolean attribute
507 if (typeof value === "string") {
508 element.setAttribute(name, "");
509 } else if (value === null) {
510 element.removeAttribute(name);
511 }
512 } else {
513 // Regular string-valued attribute
514 if (value != null) {
515 element.setAttribute(name, value.toString());
516 } else {
517 element.removeAttribute(name);
518 }
519 }
520}
182private setAttribute(attr: string, value: string) {
183 this.renderer.setAttribute(this.elementRef.nativeElement, attr, value);
184}
197private updateDom(element: JQuery<HTMLElement>, value: any) {
198 let tag = element.prop('tagName');
199 switch (tag) {
200 case 'INPUT':
201 this.updateDom_input(element, value);
202 break;
203 case 'TEXTAREA':
204 this.updateDom_normal(element, value);
205 break;
206 case 'SELECT':
207 this.updateDom_select(element, value);
208 break;
209 default:
210 this.updateDom_normal(element, value);
211 }
212}
255private updateDom_select(element: JQuery<HTMLElement>, value: any) {
256 element.val(value);
257}
3function set(el, value) {
4 $(el).val(value);
5 $('#' + $(el).data("target")).val(value);
6
7}
22function selectElement(input,inputText,element) {
23 var id = escapeId(input.attr('id'));
24 jQuery("input#" + id + "_AutoComplete").val(element.attr('id'));
25 jQuery("input#" + id + "_OldValue").val( inputText);
26 jQuery("input#" + id + "_AutoComplete").trigger("change");
27}
137extraNodeAttributes(attr) {
138 super.extraNodeAttributes(attr);
139 attr.addClass(this.getStyleSet().inputElement);
140}
9extraNodeAttributes(attr) {
10 super.extraNodeAttributes(attr);
11 attr.addClass(this.styleSheet.inputElement);
12}

Related snippets