小编Sha*_*gam的帖子

如何使用带有类名的 jquery 删除背景图像

我正在尝试使用 jquery 删除背景图像。但它没有发生,但使用相同的格式我可以更改背景颜色

<html>
<head>
<style>
h1 
{
background-image:url('paper.gif');
background-color:#cccccc;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){

     $("h1").each(function( index ) {
    $("."+$(this).attr("class")).css('background-image' , 'none');

    });

});
</script>
</head>


<h1 class="RED">This is a heading</h1>
<h1 class="YELLOW">This is a heading</h1>
<h1 class="RED">This is a heading</h1>
</html>
Run Code Online (Sandbox Code Playgroud)

html jquery class background-image

2
推荐指数
1
解决办法
9327
查看次数

标签 统计

background-image ×1

class ×1

html ×1

jquery ×1