Skip to content
Advertisement

clone 1 row of divs with another on click

I have 2 rows. Each row has 3 individual DIVs that can be selected (Clicked) by the user. When the the user clicks on any of the DIVs on the first row, there is styling in CSS to change the colour of the individual DIV (column if you like) I would like the corresponding DIV (column) in the 2nd row of DIVs to show as selected too.

JavaScript

jquery-

JavaScript

fiddle – https://jsfiddle.net/f9Lc0yjk/

Advertisement

Answer

I think a solution would be to use jQuery .index() to get a column number.

Since the elements you target are in some div.col-*, you have to check for the index of the parent.

Then, having a column number, you can target the relevant elements on the other rows.

JavaScript
JavaScript
JavaScript
Advertisement