In computer browsers I can prevent the standard anchor action normally, but when I use it in most mobile browsers it does not work.
I need to click on the link the browser does not point to the URL of the link, just show in an alert what is the URL that is in the attribute href
, the code I'm using follows: p>
$(".myGallery a").on("click touchstart", function(event){
event.preventDefault();
alert($(this).attr("href"));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><divclass="myGallery">
<a href="https://www.yourhtmlsource.com/images/media/banjotooiebig.jpg">
<img src="https://www.yourhtmlsource.com/images/media/banjotooiesmall.jpg"alt="Image">
</a>
</div>
I tried the following browsers for Android :
- Chrome 70.0.3538.110
- Chrome 34.0.1847.114
- Opera Mini 35.0.2254.127755
- CM Browser 5.22.17.0003