One way would be to extract the click function out:

function doClick() {
   var getLink = $(this).prev().prev().attr("href");
   return getLink.slice(getLink.indexOf("r=")+2, getLink.indexOf("&tp"));
}

Then:

$('#greyLink').click(doClick);

I believe that should work.



On 4/29/07, Yansky <[EMAIL PROTECTED]> wrote:


Hi guys, I was wondering about the following code and if it's possible
to chain it. At the moment it works fine as is, I'm just curious if it
is possible.

My original code:
$('#greyLink').click(function(){

var getLink = $(this).prev().prev().attr("href");
return getLink.slice(getLink.indexOf("r=")+2, getLink.indexOf("&tp"));

});

what I've tried:

$('#greyLink').click(function(){

return $(this).prev().prev().attr("href")[0].slice(this.indexOf("r=")
+2, this.indexOf("&tp"));

});

&

$('#greyLink').click(function(){

return $(this).prev().prev().attr("href").this.slice(this.indexOf("r=")
+2, this.indexOf("&tp"));

});


Reply via email to