Home >Web Front-end >JS Tutorial >How to dynamically change and set the background image in jquery_jquery

How to dynamically change and set the background image in jquery_jquery

WBOY
WBOYOriginal
2016-05-16 16:54:421679browse

Sometimes, we can provide users with very considerate functions, such as determining when the user comes to visit, and then giving a greeting, good evening, good afternoon, etc. And change the background color of the web page. For example, you can use a starry sky background at night, bright sunshine during the day, or use this theme background for specific holidays, making your website appear very flexible and not boring.

The following is a solution on how to implement background replacement:

How to achieve it

It’s very simple, here is the JQuery code:

Copy code The code is as follows:

function doChangeBkg()
{
var bkgUrl=$("#inputBkgUrl").val();
var repeateMode=$("#inputRepeatMode").val();
var s="";
$("#outputDiv").html(s);
}

Front-end code:

Copy code The code is as follows:


Background image URL: < ;input type="text" size="60" id="inputBkgUrl" />

Background image repeat mode:



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn