cjm2671
cjm2671

Reputation: 19456

What's wrong with this simple jQuery?

<script type="text/javascript">
$(document).ready(function() {
  $(".rpxnow").click();
});
</script>

I've put this into the body part of my page, in order to click on all links with class rpxnow. If I paste that line into the javascript console, it produces the desired effect, however, when I reload the page, it doesn't appear to work.

Upvotes: -1

Views: 117

Answers (3)

Naftali
Naftali

Reputation: 146302

Your problem is that your current script doesn't return anything. you need to define what the click does:

<script type="text/javascript">
$(document).ready(function() {
  $(".rpxnow").click(function(){
      alert('hi!');
      //other code...
    });
});
</script>

Upvotes: 0

Tokimon
Tokimon

Reputation: 4142

well... .click() is not really supported in all browsers, it will only trigger the click event (not the actual click) in eg. FF.

But if you ar clicking all links use $("a.rpxnow"). If you are loading the links in dynamically, then you should probably wait xx seconds before you fire the click thingy.

Upvotes: 0

Bala R
Bala R

Reputation: 108937

Seems to be working for me.

http://jsfiddle.net/9FruC/

Upvotes: 1

Related Questions