function appendRefToLinks(ref){
alert("hi");
$j('a').each(function(i){
alert('hello');
$j(this).attr('href',$j(this).attr('href') + "?ref=" + $j.cookie.get("tb_ref"));
});
}
I see the hi alert, but I have to links on my page, and I never see hello…. what am I doing wrong?
You’re probably calling the function before the page is parsed.
You need to wrap the code that calls it in
$j(function() { ... });so that it executes after the browser loads the page.