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开发者_如何学Python work.
Seems to be working for me.
http://jsfiddle.net/9FruC/
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.
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>
精彩评论