0

I need a function in JS to load an image on click only. I use an API and if i load a captcha image every page load after a few requests bans me because not all visitors enter captcha.

O i have http://site.tld/?captcha_image=3382894 wich if i load every time page loads i got banned for flood.

So i need something when visitor uses api let's say it appears a text with "Click here to enter captcha", then when it clicks the image is loaded.

I don't know JS at all, i appreciate any help... Thanks!

MRS
  • 3
  • 2

1 Answers1

1

$("button").click(function () {
    var imgUrl = $(this).data('rel');
    $("#area").html("<img src='" + imgUrl + "' alt='description' />");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button data-rel="http://www.lemis.com/grog/Photos/20110726/big/capcha.gif">Click</button>
<div id="area"></div>

Reference link

Community
  • 1
  • 1
Keerthi
  • 923
  • 6
  • 22