StealthRT StealthRT - 1 year ago 106
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>?

Answer Source

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



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download