-1

What is the best way to style the selected column of the following HTML code

    <div class="row">
        <div class="col-md-3 portfolio-item starter">
            <a href="#/starter">
                <img class="img-responsive" src="images/starter.jpg" alt="starter">
            </a>
             <h2><a href="#/starter">Starter</a></h2>
        </div>
        <div class="col-md-3 portfolio-item">
            <a href="#/salads">
                <img class="img-responsive" src="images/salads.jpg" alt="salads">
            </a>
             <h2><a href="#/salads">Salads</a></h2>
        </div>
        <div class="col-md-3 portfolio-item">
            <a href="#/main">
                <img class="img-responsive" src="images/main.jpg" alt="main">
            </a>
             <h2><a href="#/main">Main</a></h2>
        </div>
        <div class="col-md-3 portfolio-item">
            <a href="#/dessert">
                <img class="img-responsive" src="images/desserts.jpg" alt="desserts">
            </a>
             <h2><a href="#/dessert">Desserts</a></h2>
        </div>
    </div>
    <!-- /.row -->    

I have 4 columns as above, when user selects(clicks) one of the column, i want to highlight it with some style

0

1 Answer 1

2

Try this

Add main-menu class and active class

JQUERY

$('.main-menu div').on('click',function(){
  $('div').removeClass('active');
  $(this).addClass('active');
});

CSS

.active{
    background-color:green;
  }

DEMO

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.