Skip to content Skip to sidebar Skip to footer

Onclick With Foreach Css Change Jquery

I have a foreach loop in php with bootstrap collapse panel and I want to know if there is any option to change color of div.panel-heading on-click for a single title. So when I cli

Solution 1:

Do something like this using jquery:

    $('div.panel-heading a').click(function(){

    $('div.panel-heading').css('background','transparent');        

    varParentDiv = $(this).parent();

    ParentDiv.css('background','red');

});

Solution 2:

Check out this (used jquery lib ) JSfiddle

 $('div.panel-heading').click(function(){
 $('div.panel-heading').removeClass('bgcolor');
$(this).addClass('bgcolor');
 });

Post a Comment for "Onclick With Foreach Css Change Jquery"