Thursday, June 6, 2024
 Popular · Latest · Hot · Upcoming
64
rated 0 times [  70] [ 6]  / answers: 1 / hits: 80565  / 13 Years ago, mon, march 19, 2012, 12:00:00

I use jQuery's event object to get the target's parent. The code is:



event.target.parentElement


In Chrome it works, but in Firefox, it doesn't. I use alert() to print the output.



event.target is an URL in both Chrome and Firefox; but event.target.parentElement in Chrome is [Element object], and in Firefox it is null.



What should I do to solve this problem? I still wonder if IE will have this problem?



Thanks.


More From » jquery

 Answers
54

To access the parent, you could do:




var par = $(event.target).parent();

[#86756] Saturday, March 17, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gabriel

Total Points: 323
Total Questions: 107
Total Answers: 108

Location: Federated States of Micronesia
Member since Sun, May 16, 2021
3 Years ago
gabriel questions
Sun, Feb 14, 21, 00:00, 3 Years ago
Tue, Dec 8, 20, 00:00, 4 Years ago
Mon, Jun 8, 20, 00:00, 4 Years ago
Tue, May 19, 20, 00:00, 4 Years ago
;