I have the following HTML on my page:
<a data-href="/C003Q/History"><span>History</span></a>
Is there a JQuery selector that will allow me to send a click event to the link?
You can use attribute selector,
Live Demo
$('a[data-href="/C003Q/History"]').click(function(){
alert("clicked");
});
Use this method if you want to trigger the click event:
$('a[data-href="/C003Q/History"]').click();
Or use the following code if you want to pass a click handler to the link:
$('a[data-href="/C003Q/History"]').click(function(){
console.log("click");
//And do your logic here
});
This works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With