Home » JQuery » JQuery get href value of anchor tag in clicked li tag

JQuery get href value of anchor tag in clicked li tag

I have the following list items with each anchor tags.So I need to get each clicked list item’s anchor tag href value.Here tested solutions and possible errors of the discussions beyond the expectation.

If you clicked on the Google.com, you want to get that clicked li tag’s anchor tag url.
You can get that clicked href values as following methods using simple jquery.

Mehtod-1

Mehtod-2 – Using find selector

Mehtod-3 – using children selector

Mehtod-4

Note:
return false from within a jQuery event handler is effectively the same as calling both e.preventDefault() and e.stopPropagation() on the passed jQuery Event objects.

e.preventDefault() will prevent the default event from occurring.
e.stopPropagation() will prevent the event from bubbling up/propagating the DOM.
return false will do both.

Note that this behavior differs from normal (non-jQuery) event handlers, in which, notably, return false does not stop the event from bubbling up/propagating.

This is showing …..

Tags

Similar posts