Home Web Front-end JS Tutorial Detailed explanation of jQuery dynamically removing and adding background images

Detailed explanation of jQuery dynamically removing and adding background images

Jan 23, 2018 am 11:25 AM
jquery Example Background picture

This article mainly introduces jQuery's method of dynamically removing and adding background images, and analyzes jQuery's dynamic operation skills for page element styles and event responses in the form of examples. Friends who need it can refer to it. I hope it can help everyone.

Use jQuery to remove and add images

1, Style


<style type="text/css">
  .changeImage{
     background:url(images/right.png) no-repeat center;
  }
</style>
Copy after login

2, JS

(1) When changing the style of the label, you need to remove the previously added style


$("#tab tr").find("td").removeClass("changeImage");
Copy after login

(2) Add the style


$("#tab tr").find("td").addClass("changeImage");
Copy after login

Attachment: Complete example demo:






jQuery移除和添加图片


<script>
function removeimg(){
$(&quot;#tab tr&quot;).find(&quot;td&quot;).removeClass(&quot;changeImage&quot;);
}
function addimg(){
$(&quot;#tab tr&quot;).find(&quot;td&quot;).addClass(&quot;changeImage&quot;);
}
</script>


  
制造商型号说明价值
1997FordE350"ac abs moon"3000.00
1999Chevy"Venture ""Extended Edition"""""4900.00
1999Chevy"Venture ""Extended Edition Very Large"""""5000.00
1996JeepGrand Cherokee"MUST SELL!
air moon roof loaded"4799.00
Copy after login

Related recommendations:

Use css to add background to elements of unknown width and height Image method

How to add a background image in a php file

css strange usage of IMG to add a background image to match the display effect is stunning_html/css_WEB -ITnose

The above is the detailed content of Detailed explanation of jQuery dynamically removing and adding background images. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to add a background image to Douyin Live Companion - How to add a background image to Douyin Live Companion How to add a background image to Douyin Live Companion - How to add a background image to Douyin Live Companion Mar 05, 2024 am 09:16 AM

Many users who live broadcast on Douyin will use the Douyin Live Companion software, but do you know how to add a background image to the Douyin Live Companion? The following is the method of adding a background image to the Douyin Live Companion brought to you by the editor. If you are interested Users, please come and take a look below. First log in to Douyin Live Companion on your computer, and then enter the homepage. On the left, we select [Add Material] under [Scene 1]. Next, there will be a window to add materials on the page. We can directly select the [Picture] function and click to enter. We will then open a window where the image material is stored locally. We need to select the picture materials we want to add and then click the Open button in the lower right corner to add them. After adding the picture, we need to use the left mouse button to drag the picture to the appropriate

How to uniformly replace ppt background images How to uniformly replace ppt background images Mar 25, 2024 pm 04:16 PM

The unified replacement of PPT background images is an important operation to improve the visual style of presentations, and can be achieved through two main methods: slide master replacement and batch replacement. Slide master replacement involves deleting the original image and inserting a new image in the master, thereby applying to all slides. The batch replacement function directly replaces the background images of all slides in the presentation. A unified background image not only enhances your presentation but also enhances your audience's focus. It is important to choose high-quality images that are consistent with the theme, and you should pay attention to adjusting details such as transparency and size. In addition, PPT also provides rich background setting options, such as gradients, textures and patterns, which can be customized according to needs.

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

Introduction to setting background images in WPS Office 2016 Introduction to setting background images in WPS Office 2016 Mar 29, 2024 pm 10:21 PM

1. Start the WPS demonstration, as shown in the figure. 2. Click the [+] button to create a new slide, as shown in the figure. 3. Right-click and select [Background], as shown in the figure. 4. In the fill options on the [Object Properties] page, select [Picture or Texture Fill], as shown in the figure. 5. In the image source, click Local File[, as shown in the figure. 6. In the dialog box, select the picture you want to insert, and click the ] to open the [ button, as shown in the example. 7. This completes the background image setting for the WPS demonstration. The effect is as shown in the picture.

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: &lt

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on ​​the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

The relationship between the number of Oracle instances and database performance The relationship between the number of Oracle instances and database performance Mar 08, 2024 am 09:27 AM

The relationship between the number of Oracle instances and database performance Oracle database is one of the well-known relational database management systems in the industry and is widely used in enterprise-level data storage and management. In Oracle database, instance is a very important concept. Instance refers to the running environment of Oracle database in memory. Each instance has an independent memory structure and background process, which is used to process user requests and manage database operations. The number of instances has an important impact on the performance and stability of Oracle database.

See all articles