thanks for your time and first of all I'm a noobie who's been learning by his own javascript so I don't manage quite good the selectors to achieve what I want. Here it's my problem: html <ul id='stuff' class='goods'> <li>list item 1</li> <li>list item 2</li> <li>list item 3</li> <li><span class='highlighted'>list item 4</span></li> <li>list item 5</li> </ul> <ul id='stuff2' class='goods'> <li>list item 1</li> <li>list item 2</li> <li>list item 3</li> <li>item 4</li> <li>list item 5</li> </ul> CSS .highlighted{ color: red; } .goods{ border:1px solid red; cursor: pointer; padding: 0px; list-style: none; } .match_group{ border: 1px solid black; } Look here pelase: * http://jsfiddle.net/nero_noob_123/ctcn7kfy/2/ basically what I want to achieve with the jquery and javascript it's the following.... but I don't know how write it as a condition so try to read it as follows: $('#stuff2').addClass('match_group'); $('#stuff2').addClass('match_group'); if($('li').has('span.highlighted').length){ //so span exist! $('span.highlighted').closest('.goods').addClass('match_group'); }else if($('.goods').hasClass('match_group') && // span.highlight DOESN'T EXIST inside .goods) { /// remove the match_group class from '.goods' where span.highlight doesn't exist }else{ if any of the '.goods' classes has span.highlighted inside them, don not apply .match_group }
if($('li').has('span.highlighted').length > 0)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)