10 examples of 'changing background image jquery' in JavaScript

Every line of 'changing background image 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
290function setBackgroundStyles(image_url){
291 if (typeof image_url === 'string')
292 _currentImageURL = image_url;
293 else if (typeof _currentImageURL !== 'string')
294 return;
295 let url = _currentImageURL.replace(/"/g, '%22'),
296 styles = '#image{background-image:url("'+url+'");background-size:'+settings.crop+'}';
297 if (settings.crop === 'contain'){
298 $imageGhost.css('opacity','');
299 styles += '#image-ghost{display:block;background-image:url("'+url+'")}';
300 }
301
302 $style.html(styles);
303}
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

153function changedBackgroundImage() {
154 var formObj = document.forms[0];
155 var st = tinyMCE.parseStyle(formObj.style.value);
156
157 st['background-image'] = "url('" + formObj.backgroundimage.value + "')";
158
159 formObj.style.value = tinyMCE.serializeStyle(st);
160}
50applyBackground(img) {
51 let elm = document.querySelector('.app');
52 elm.style.backgroundImage = `url(${img.src})`;
53}
59function usebackground (id) {
60 $("#stats").html(tabledefault);
61 var bglist = backgrounddata.compendium.background;
62 var curbg = bglist[id];
63
64 var name = curbg.name;
65 $("th#name").html(name);
66
67 var traitlist = curbg.trait;
68 $("tr.trait").remove();
69 for (var n = traitlist.length-1; n >= 0; n--) {
70 var traitname = traitlist[n].name;
71 var texthtml = "<span class='name'>"+traitname+".</span> ";
72 var textlist = traitlist[n].text;
73 texthtml = texthtml + "<span>"+textlist[0]+"</span> "
74
75 for (var i = 1; i < textlist.length; i++) {
76 if (!textlist[i]) continue;
77 if (textlist[i].indexOf ("Source: ") !== -1) continue;
78 texthtml = texthtml + "<p>"+textlist[i]+"</p>";
79 }
80
81 $("tr#traits").after("<tr class='trait'><td colspan='6' class='trait"+i+"'>"+texthtml+"</td></tr>");
82 }
83
84};
304_updateBackgroundImage(img) {
305 img.parentNode.style.backgroundImage = `url("${(img.currentSrc || img.src)}")`;
306}
77function changeiuiBackground2(obj,loading){
78 if(!parent.ISMOBILE) return false;
79
80 if(loading){
81 document.getElementById(obj).style.background = 'url(/images/InternetScan.gif) no-repeat right center';
82 document.getElementById(obj).style.marginRight = '5px';
83 }
84 else{
85 }
86}
360value: function background_selected_handler(event) {
361 var img = $(this).attr('data-img');
362
363 if ('random' === img) {
364 this.cache_set('true', 'background_manager', 'randmom_background');
365 img = this.get_random_image();
366 }
367
368 this.cache_set(img, 'background_manager', 'current_background');
369 this.current_background = img;
370
371 this.do_background();
372}
212function Background(image, color, opacity)
213{
214 this.image = image ? image : null;
215 this.color = color ? color : null;
216 this.opacity = opacity ? opacity : color ? color.alpha : 0;
217}
43function setBackground(e) {
44 var myHTML = document.querySelector('html');
45 myHTML.style.backgroundImage = "url('" + e.target.src + "')";
46}
6function readBackgroundImage(event) {
7 const reader = new FileReader();
8 reader.onloadend = function onloadend(readerEvent) {
9 const image = new Image();
10 image.onload = async function imageResized() {
11 const imageUrl = resizeImage(image, MAXSIZE);
12 await db.backgroundImg.add({ imageUrl });
13 document.getElementById('resetImageDiv').style.display = 'inherit';
14 document
15 .getElementsByTagName('body')[0]
16 .style
17 .backgroundImage = `linear-gradient(rgba(0, 0, 0, 0.35),rgba(0, 0, 0, 0.35)), url("${imageUrl}")`;
18 };
19 image.src = readerEvent.target.result;
20 // Reset image, in case someone wants to upload two times the same image
21 document.getElementById('backgroundUpload').value = '';
22 };
23 const file = event.target.files[0] || event.dataTransfer.files[0];
24 if (file) {
25 const isImage = /\.(?=gif|jpg|png|jpeg)/gi.test(file.name);
26 if (isImage) {
27 reader.readAsDataURL(file);
28 }
29 }
30}

Related snippets