scifirocket scifirocket - 6 months ago 40
Javascript Question

F is Undefined - Jquery

I have some jquery code that uses the live method of triggering events:

$(document).ready(function() {
$('.cross-link').live(function() {
$('a[href=#2').click();
});
});


Where
cross-link
elements can be generated after the DOM has loaded.

Firebug reports that
F is undefined
. It references the last line in my jquery.js file that begins with
(function(){var Q=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]+['"]|[^[\]'"]+)...
ect. I read that it may be the case that my Jquery library is out of date. So I downloaded the latest version, but it produced other errors.

What should I be looking for to fix this?

Answer

Live needs even handler. Modify your code like this:

$(document).ready(function() {
  $('.cross-link').live('click', function() {
    $('a[href=#2').click();
  });
});