Home > Article > Web Front-end > What to do if jquery does not display the image background
jquery does not display the image background because the path is incorrect. The solution: 1. Open the corresponding js file; 2. Pass "let src='clock/img/afternoon.png';them_icons.css( 'background','url(' src ')')" method can be used to reset the background image.
The operating environment of this tutorial: Windows 10 system, jquery version 3.2.1, DELL G3 computer
What should I do if jquery does not display the image background? ?
The solution in jquery is to set the image not to be displayed
The solution to the setting background image in jquery is not to be displayed
let src='clock/img/afternoon.png'; them_icons.css('background','url('+src+')')
The main problem lies in the path, the relative path is relative to the html file With the path of the image, not the path of the js file relative to the image.
Related knowledge expansion:
jq realizes changing pictures by clicking the button
##Attached jq code:$(function(){ $("#btn1").click(function(){ $("img").attr("src","img/01.jpg") }) $("#btn2").click(function(){ $("img").attr("src","img/02.jpg") }) $("#btn3").click(function(){ $("img").attr("src","img/03.jpg") }) });Recommended Study: "
jQuery Video Tutorial"
The above is the detailed content of What to do if jquery does not display the image background. For more information, please follow other related articles on the PHP Chinese website!