my javascript looks like this:
$(document).ready(function() {
$("a:not(.noajax)", $('#header, #content')).live('click', function(event) {
ajaxCall($(this).attr("href"));
event.preventDefault();
});
)};
The $(this) selector doesn't seem to get the 'a' object, it works fine however without a selector context. What am I doing wrong here?
Looks like jQuery converts select开发者_如何转开发ors with context into :
$(context).find(selector)
So I think that my $(this) refers to the context rather than the selctor. Any ideas?
The context should be an element or a string, not a jQuery object. Furthermore, since ids are unique, you only need one context here.
$("a:not(.noajax)", '#header').live('click', function(event) {
ajaxCall($(this).attr("href"));
event.preventDefault();
});
See a live example.
精彩评论