StealthRT StealthRT - 5 months ago 24
jQuery Question

Finding previous tag name using jQuery Prev()

Hey all I am using the following code to go back 1 in order to find the start of the tag name:


This produces this result:


However, that is incorrect since it should be < g>
enter image description here

If I do this:


I get this:

enter image description here

So I know its getting the correct area but how can I go about getting the < g>?


g tag is parent of text elements. You need to use .parent() or .closest() selector for traversing to parent element: