jhon de jhon de - 5 months ago 11
jQuery Question

How do i trigger click on scr image under href

I want to trigger click on estrela_16.gif

Html

<img src="https://www.bux.com/imagens/estrela_16.gif" border="0" height="16" width="16">

Answer

You can simply use the jQuery selector to achieve that, like this:

$("img[src*='estrela_16.gif']").on('click', function() {
 // Do something...
});

In case you want to trigger the click event, do this:

$("img[src*='estrela_16.gif']").trigger('click');

or more direct:

$("img[src*='estrela_16.gif']").click();

More information can be found here https://api.jquery.com/attribute-contains-selector/, and here http://api.jquery.com/trigger/