Search code examples
jqueryhtmlclassbackground-image

how to remove the background image using jquery with class name


I'm trying to remove the background image using jquery.But its not happening, But using the same format i can change the background color

<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>

Solution

  • <script>
    $(document).ready(function(){
    
    
    
         $("h1").each(function( index ) {
         $("."+$(this).attr("class")).css({"background":"none"});
    
    
    
        });
    
    });
    </script>