$(document).ready(function() { $("a[id='reload_captcha']").click(function(e) { e.preventDefault(); $("#captcha_image").attr('src', base_url + "/index.php?q=captcha&" + Math.random()); }); });