How to refresh the src of

前端 未结 4 1933
小鲜肉
小鲜肉 2020-12-03 01:30

where test.php generates an image with a random number.

Itried :

$(\'#verifyimage\').click(f         


        
4条回答
  •  再見小時候
    2020-12-03 01:51

    Taking KPrimes great answer and adding in trackers suggestion, this is what I came up with:

    jQuery(function($) {
        // we have both a image and a refresh image, used for captcha
        $('#refresh,#captcha_img').click(function() {
           src = $('#captcha_img').attr('src');
       // check for existing ? and remove if found
           queryPos = src.indexOf('?');
           if(queryPos != -1) {
              src = src.substring(0, queryPos);
           }    
           $('#captcha_img').attr('src', src + '?' + Math.random());
           return false;
        });
    });
    

提交回复
热议问题