10 examples of 'jquery change src of image' in JavaScript

Every line of 'jquery change src of image' 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
78function getImageSrc(src) {
79 return window.isLocal ? '/demo/' + src : src;
80}
122function setImage(el, src) {
123
124 var image = new Image();
125
126 image.onload = function() {
127 el.setAttribute('src', src);
128 };
129
130 image.src = src;
131}
67function setImage(element, url) {
68 var property = "url(" + url + ")";
69 element.style.backgroundImage = property;
70}
369function removeSRC(img) {
370 if (img) {
371 img.removeAttribute('onerror')
372 img.src = null
373 img.removeAttribute('src')
374 }
375}
1275function imageLoaded(image, callback) {
1276
1277 if (!image.nodeName || image.nodeName.toLowerCase() !== 'img')
1278 return callback(new Error('First argument must an image element'));
1279
1280 if (image.src && image.complete && image.naturalWidth !== undefined)
1281 return callback(null, true);
1282
1283 image.addEventListener('load', function() {
1284 callback(null, false);
1285 }.bind(this));
1286
1287 image.addEventListener('error', function(e) {
1288 callback(new Error('Failed to load image \'' + (image.src || '') + '\''));
1289 }.bind(this));
1290
1291 if (image.complete) {
1292 src = image.src;
1293 image.src = BLANK;
1294 image.src = src;
1295 }
1296}
137function setSrc (element, src, name) {
138 name || (name = 'src');
139
140 if (!element.getAttribute(name) || (element.getAttribute(name) !== src)) {
141 element.setAttribute(name, src);
142 }
143}
79function preloadImg(image) {
80 var img = new Image();
81 img.src = image;
82}
868function loadImage(src, callback) {
869 var img = new Image();
870 img.onload = function () {
871 callback.apply(this, arguments);
872 };
873 img.src = src;
874 return img;
875}
42setSrc(src) {
43 this._planet && this._planet._geoImageCreator.remove(this);
44 this._src = src;
45 this._sourceReady = false;
46}
165function isImageLoaded($img){
166 return $img.get(0).complete;
167};

Related snippets