Reputation: 6509
Why am I getting this error on my code?
Cannot read property 'attr' of undefined`
$(document).ready(function() {
var currentPage = jQuery.url.attr("path");
$(':input').blur(function () {
if ($(this).val().length > 0) {
pageTracker._trackEvent("Form: " + currentPage, "input_exit", $(this).attr('name'));
}
});
});
My fiddle: https://jsfiddle.net/4ocdcqrf/
Upvotes: 2
Views: 13621
Reputation: 1066
If you do a console log on jQuery.url, you will see this is has a value of undefined.
you will needd to use location.pathname instead of jQuery.url.
Please take a look here for proper understanding
Upvotes: 1
Reputation: 5648
The issue is that jQuery.url
is undefined. I'm not sure where you even got the idea that this property should exist, since it's not part of jQuery. To get the actual current page, you can simply get the native property
window.location.href
Upvotes: 0