Amresh Amresh - 1 month ago 11 Question

Click an anchor tag in

Please suggest a method in to perform 'onclick' event on clicking the image in anchor tag.

<td style="border: 0px solid white; border-image: none;">

<div id="clickAnImage100">

<a onclick="GetMyWebsite('');" href="#!">
<img height="34" src="../images/WebClick.png">

</div> </td>



In any of your JavaScript file, you can simply do that by

$( "img" ).click(function() {
  //your logic


give a class to your image say trigger

<a onclick="GetMyWebsite('');" href="#!">
   <img height="34" src="../images/WebClick.png" class="trigger">

& then in your JavaScript file you can

$( ".trigger" ).click(function() {
  //your logic

If you're looking to "programmatically" call a click inside the onclick event, then what you need is trigger() method of jquery. This function "fakes" a click event on an element. Can be used like:

function GetMyWebsite(link_passed) {
  $(".first").attr("href", link_passed);
  $( ".second" ).trigger( "click" );
  //your logic

$( ".second" ).click(function() {
  alert('You called me from first');

Here is a codepen I created to show you the same. Also the explanation to tigger() method from JQueryAPI.

Updated answer as you need way of getting this done.

In, all you need is PerformClick() method like so:

Obviously you need to replace the Button2 to your desired Control(anchor tag control) which you want to click

Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
    'do stuff
End Sub

This is just an example of PerformClick(), you can call it wherever you want to & make perform a click on the anchor tag