10 examples of 'placeholder in jquery' in JavaScript

Every line of 'placeholder in jquery' 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
59function showPlaceholder(elem) {
60 var type, maxLength, val = elem.getAttribute(ATTR_CURRENT_VAL);
61 if (elem.value === "" && val) {
62 elem.setAttribute(ATTR_ACTIVE, "true");
63 elem.value = val;
64 elem.className += " " + placeholderClassName;
65 // Store and remove the maxlength value
66 maxLength = elem.getAttribute(ATTR_MAXLENGTH);
67 if (!maxLength) {
68 elem.setAttribute(ATTR_MAXLENGTH, elem.maxLength);
69 elem.removeAttribute("maxLength");
70 }
71 // If the type of element needs to change, change it (e.g. password inputs)
72 type = elem.getAttribute(ATTR_INPUT_TYPE);
73 if (type) {
74 elem.type = "text";
75 } else if (elem.type === "password") {
76 if (Utils.changeType(elem, "text")) {
77 elem.setAttribute(ATTR_INPUT_TYPE, "password");
78 }
79 }
80 return true;
81 }
82 return false;
83}
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

163function showPlaceholder(elem) {
164 var type,
165 val = elem.getAttribute(ATTR_CURRENT_VAL);
166 if (elem.value === "" && val) {
167 elem.setAttribute(ATTR_ACTIVE, "true");
168 elem.value = val;
169 elem.className += " " + placeholderClassName;
170
171 // If the type of element needs to change, change it (e.g. password inputs)
172 type = elem.getAttribute(ATTR_INPUT_TYPE);
173 if (type) {
174 elem.type = "text";
175 } else if (elem.type === "password") {
176 if (Utils.changeType(elem, "text")) {
177 elem.setAttribute(ATTR_INPUT_TYPE, "password");
178 }
179 }
180 return true;
181 }
182 return false;
183}
10function getPlaceholder(language, index) {
11 return '___' + language.toUpperCase() + index + '___';
12}
43function initInputPlaceholders(){
44 // Note: see global.js for the event handlers
45 $("input").each(function(){
46 if($(this).val()==''&&($(this).attr("type")=='text'||$(this).attr("type")=='password')&&typeof $(this).attr("placeholder")!==typeof undefined&&$(this).attr("placeholder")!==false){
47 $(this).val($(this).attr("placeholder"));
48 $(this).data('placeholder', $(this).attr("placeholder"));
49 $(this).removeAttr('placeholder');
50 }
51 });
52 $("textarea").each(function(){
53 if($(this).val()==''&&typeof $(this).attr("placeholder")!==typeof undefined&&$(this).attr("placeholder")!==false){
54 $(this).val($(this).attr("placeholder"));
55 $(this).data('placeholder', $(this).attr("placeholder"));
56 $(this).removeAttr('placeholder');
57 }
58 });
59}
47function preparePlaceholder() {
48
49 if (!document.createElement) {
50 return false;
51 }
52 if (!document.createTextNode) {
53 return false;
54 }
55 if (!document.getElementById) {
56 return false;
57 }
58 if (!document.getElementById('imageGallery')) {
59 return false;
60 }
61 var imgElement = document.createElement("IMG");
62 imgElement.src = "../picture/benchi.jpg";
63 imgElement.alt = "my image gallery";
64 imgElement.id = "placeholder";
65
66 var pElement = document.createElement("p");
67 pElement.id = "description";
68
69 var txt = document.createTextNode("Choose one picture !");
70
71 var galleryNode = document.getElementById('imageGallery');
72 insertAfter(imgElement, galleryNode);
73 pElement.appendChild(txt);
74 insertAfter(pElement, imgElement);
75}
35setPlaceholder(placeholder) {
36 this._findDOMEl(
37 '.hig__global-nav__top-nav__search__input',
38 this.el
39 ).setAttribute('placeholder', placeholder);
40}
45setPlaceholder(placeholder) {
46 this._findDOMEl('.hig__global-nav__side-nav__search__inputholder__input', this.el).setAttribute('placeholder', placeholder);
47}
22function jq(id: string): string {
23 return id.replace(/(@|:|\.|\[|\]|,)/g, "\\$1");
24}
1607function replaceHolders(array, placeholder) {
1608 var index = -1,
1609 length = array.length,
1610 resIndex = 0,
1611 result = [];
1612
1613 while (++index < length) {
1614 var value = array[index];
1615 if (value === placeholder || value === PLACEHOLDER) {
1616 array[index] = PLACEHOLDER;
1617 result[resIndex++] = index;
1618 }
1619 }
1620 return result;
1621}
274function updatePlaceholder(s, se) {
275 var e = $$$(se, 'a');
276 e.href = '#';
277}

Related snippets