I have two links that have different structure.
<div id="content">
<a href="javascript:void(0)" data-uri="https://stackoverflow.com/questions/ask">
and
<a href="javascript:void(0)" data-uri="https://stackoverflow.com/questions/ask">
<img src="https://www.gravatar.com/avatar/084f45fb1ccb4bd208ad48dbffcd502f?s=48&d=identicon&r=PG">
</a>
</div>
I have this function that should log data-uri by clicking <a>
element.
var clickHandler = "click";
if ('ontouchstart' in document.documentElement) {
clickHandler = "touchstart";
}
$(document).on(clickHandler, '#content a', function() {
href = $(this).data("uri");
console.log(href);
});
For some reason link with image just does not work. Nothing get logged.
PS. clickHandler variable is there adapt if page is viewed by mobile device that has touch feature.