Get the App
SLTechnology News&Howtos  ›  Development  › 

How to remove body background Picture by jquery

Shulou Source: shulou.com Published: 2022-05-31 20:08:46 10月05日 Update

This article mainly explains "how jquery removes body background pictures". The explanation in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "how jquery removes body background pictures".

Methods to remove body background pictures: 1. Use css (), syntax "$(" body "). Css (" background "," none ");"; 2, use attr (), syntax "$(" body "). Attr (" style "," background:none ");".

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

The method of removing body background Picture by jquery

Method 1: use css ()

The css () method returns or sets one or more style properties of the matching element.

Use the css () method to directly add a new value "none" to the background property and set the new style.

Body {background: url (img/2.png) no-repeat } $(document) .ready (function () {$("button") .click (function () {$("body") .css ("background", "none") }); remove the body background image

Method 2: use attr ()

Use attr () to set the style property, add the background:none style, and overwrite the old style.

Body {background: url (img/2.png) no-repeat } $(document) .ready (function () {$("button") .click (function () {$("body") .attr ("style", "background:none") }); remove the body background image

Thank you for your reading, the above is the content of "jquery how to remove body background pictures". After the study of this article, I believe you have a deeper understanding of how jquery removes body background pictures, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Pictures backgrounds background pictures methods styles attributes learning content grammar elements multiple that is ideas situations tutorials articles more versions environment computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Tech Info macOS Microsoft MariaDB