I work with an unordered list of links. When a user clicks on the ‘li’ tag that doesn’t have .myclass ––
$('#access li:not(.myclass)').click(function(event) {
— certain animated effects occur, and then I want to go to the url of the link associated with the ‘li’ tag that was clicked.
This code ––
var url = $(this).attr('href')
–– would get me the necessary url if I were initially selecting the ‘a’ – but for a certain number of reasons I have to select ‘li’.
My attempt: var url = $(this>'a').attr('href') was obviously doomed to failure.
Question: how can I get the ‘href’ attribute of the clicked ‘li’ element?
I’d be grateful for your advice!
Try: