Every line of 'add placeholder using 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.
47 function 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 }
10 function getPlaceholder(language, index) { 11 return '___' + language.toUpperCase() + index + '___'; 12 }
59 function 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 }
163 function 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 }
70 createPlaceholderCallback() { 71 testElementCreatePlaceholderCallback(); 72 }
71 that.modal.on('cms.modal.loaded cms.modal.closed', function removePlaceholder() { 72 // cannot be cached 73 $('.cms-add-plugin-placeholder').remove(); 74 }).on('cms.modal.closed cms.modal.load', function () {
45 setPlaceholder(placeholder) { 46 this._findDOMEl('.hig__global-nav__side-nav__search__inputholder__input', this.el).setAttribute('placeholder', placeholder); 47 }
35 setPlaceholder(placeholder) { 36 this._findDOMEl( 37 '.hig__global-nav__top-nav__search__input', 38 this.el 39 ).setAttribute('placeholder', placeholder); 40 }
43 function 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 }
101 function placeholder_select_language() { 102 jQuery( document ).on( 'change', '.placeholder_select_language', function () { 103 var new_value = jQuery( this ).val(); 104 var select_name = jQuery( this ).attr( 'name' ); 105 106 // get new name 107 select_name = select_name.substr( 0, select_name.lastIndexOf( '[' ) ); 108 select_name += '[' + new_value + ']'; 109 110 // rename select field 111 jQuery( this ).attr( 'name', select_name ); 112 113 // rename textarea 114 jQuery( this ).parent().next().find( 'textarea' ).attr( 'name', select_name ); 115 } ) 116 }