PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 27, 2022

[FIXED] how to remove the background image using jquery with class name

 October 27, 2022     background-image, class, html, jquery     No comments   

Issue

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>


Answered By - Shanmugam
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing