I have this block of code in my html file
<img id="capt1" src=https://picsum.photos/100 alt=foo onclick="reply_click(this.id)">
<div id="capta">Image caption text</div>
<img id="capt2" src=https://picsum.photos/100 alt=foo onclick="reply_click(this.id)">
<div id="captb">Image caption text 2</div>
<img id="capt3" src=https://picsum.photos/100 alt=foo onclick="reply_click(this.id)">
<div id="captc">Image caption text 2</div>
<script type="text/javascript">
function reply_click(clicked_id)
{
if (clicked_id="capt1"){
alert(clicked_id);
document.getElementById("capta").innerHTML="pico";
}
if (clicked_id="capt2"){
alert(clicked_id);
document.getElementById("captb").innerHTML="pico2";
}
if(clicked_id="capt3"){
alert(clicked_id);
document.getElementById("captc").innerHTML="pico3";
}
}
</script>
when I click in any of the iamges, the alert event returns, one at a time, all the ids from the img elements. Why is it not returning ONLY the id of the img being clicked?