How to add js in the code so that in List 1 you can select only one subparagraph 1 and the selected cell highlights in a different color and in parallel so that you can make a choice in list 2 only one item with ...

https://jsfiddle.net/Alexboo/tkwkpq8r/5/

Found a script, but it does not work to apply it .....

$("#selectBackground ul li a").click(function(e) { e.preventDefault(); $("#selectBackground ul li a").removeClass('active'); $(this).addClass('active'); }) 

Here is a link to this script in jsfiddle

    1 answer 1

    It is necessary to limit the set of mutually exclusive elements to members of the same list:

     $("#selectBackground ul li a").click(function(e) { e.preventDefault(); $(this).closest("ul").find("li a").removeClass('active'); $(this).addClass('active'); }); 

    https://jsfiddle.net/tkwkpq8r/6/