Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi!
i want to know how can i change background image of div with class indentation level 0 when i click on div with class categorylist like
$(".categorylist").click(function(){
// change background image - of this.categorylist div class="indentation level 0"
and again switch to other image + when i click again
<div class="categorylist ">

<div class="indentation level3">
<div class="indentation level2">
<div class="indentation level1">
<div class="indentation level0">
<a href="http://localhost/moodle/course/category.php?id=19">level4</a>

</div>
</div>
</div>
</div>
</div>


<div class="categorylist ">

<div class="indentation level3">
<div class="indentation level2">
<div class="indentation level1">
<div class="indentation level0">
<a href="http://localhost/moodle/course/category.php?id=19">level4</a>

</div>
</div>
</div>
</div>
</div>
Posted
Comments
kiran dangar 3-Oct-11 3:08am    
can you explain a bit more on what you are targeting to achieve, so i can answer properly.

1 solution

This might be helpful:
JavaScript
$(".categorylist").click(function()
        {
        var childDiv=$(this).find(".indentation_level_0");
        if(childDiv.css("background_image")=="YouFirstImagePath")
        {
        childDiv.css("background_image","YouSecondImagePath");
        }
        else
        {
        childDiv.css("background_image","YouFirstImagePath");
        }
});
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900