What it should do:
- check is there
.box-wrapperin the doc - if yes and there is an click event on
.tabs li a - find
.selectedand set class to empty string - find parent of
this– clicked link and add.selected
And in the last step it is failing as you can see.
console.log( $('this').parent('li') ); = []
Why? What is wrong? Any suggestion much appreciated.
thisis an DOM object, not a selector string, so you need:instead of:
$('this')will cause jQuery to construct an object which wraps all elements matching your selector. ‘this’ is not a valid selector, so you get that ‘selector unintelligible’ error, whereas$(this)refers to the jQuery-wrapped clicked anchor.