Simulating click doesn't work
I'm trying to simulate a click, but nothing happens. Here is my code:
- $(document).ready(function() {
- $(".linkall")
- .click(function() {
- $(this).find("a:last").click();
- })
- .find("a").click(function(event) {
- event.stopPropagation(); // needed to prevent an endless loop. Also, because this click has presedence over the other click, this prevents all links from resulting in the same page
- });
- });
Here is my HTML:
- <div class="category linkall block">
- <img src="products/drill-pipes.png" />
- <h3>DRILL PIPE & ACCESSOIRES</h3>
- <p>Our complete product overview</p>
- <p><a href="#">CLICK HERE ►</a></p>
- </div>
When I click the link, it works fine, but when I click the text, nothing happens. The click() event does get fired though, because when I put an alert in it (after "event.stopPropagation()"), it fires.
I could use a simple "window.location", BUT sometimes the link already has an event bound to it which returns false, meaning the link should not open in a new page, but for example in a dialog. However there's no way to find this out AFAIK.
Does anyone know how to do this?