Try this instead: $('a', data).click(function(){ var href = $(this).attr('href'); [etc...] });
When using $('a', data).attr('onclick', 'javascript:your code goes here'); the 2nd parameter should be a string, as if you were doing <a href="#" onclick="javascript:your code goes here">foo</a> On Dec 18, 12:55 pm, Namotco <namo...@gmail.com> wrote: > Here is what I'm trying to do: > $("#MTB").load(url +" #content", function(data) { > $("a", data).attr("onclick",function (arr) > { > var href=this.attr('href'); > if (href.match('string') ) {return > "getMTB > (this.href); return false;"; } else { return 'alert(this.href); return > false;' ;} > }); > }); > It doesn't seem to work though