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>
2, JS
(1) When changing the style of the label, you need to remove the previously added style
$("#tab tr").find("td").removeClass("changeImage");
(2) Add the style
$("#tab tr").find("td").addClass("changeImage");
Attachment: Complete example demo:
jQuery移除和添加图片 <script> function removeimg(){ $("#tab tr").find("td").removeClass("changeImage"); } function addimg(){ $("#tab tr").find("td").addClass("changeImage"); } </script>
年 | 制造商 | 型号 | 说明 | 价值 | ||
1997 | Ford | E350 | "ac | abs | moon" | 3000.00 |
1999 | Chevy | "Venture ""Extended Edition""" | "" | 4900.00 | ||
1999 | Chevy | "Venture ""Extended Edition | Very Large""" | "" | 5000.00 | |
1996 | Jeep | Grand Cherokee | "MUST SELL! | |||
air | moon roof | loaded" | 4799.00 |
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
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!