最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - JavaScript - Click all buttons with Class Name after 5 seconds (Twitter) - Stack Overflow

programmeradmin4浏览0评论

I've been trying to get my script to work for ages now, and it just won't have it! I'm trying to click all the 'unfollow button's on my Twitter/Following page after 5 seconds. Here's my code without the setInterval function:

var buttonArray = document.getElementsByClassName('w-button-mon w-button-unfollow'); for(var a=0;a<buttonArray.length;a++){ buttonArray[0].click(); } 

Here's Twitters HTML DOM code for the unfollow buttons:

    <span class="w-button-mon w-button-unfollow"><input alt="Follow" src=".gif" type="image"></span>
  <input type="hidden" name="scribe_item" value="description=list&amp;id=1875185790&amp;item_type=3">
</form>
</td>

I'd be so appreciated if someone could amend my code! Thank you so much in advance!

I've been trying to get my script to work for ages now, and it just won't have it! I'm trying to click all the 'unfollow button's on my Twitter/Following page after 5 seconds. Here's my code without the setInterval function:

var buttonArray = document.getElementsByClassName('w-button-mon w-button-unfollow'); for(var a=0;a<buttonArray.length;a++){ buttonArray[0].click(); } 

Here's Twitters HTML DOM code for the unfollow buttons:

    <span class="w-button-mon w-button-unfollow"><input alt="Follow" src="https://ma.twimg./twitter-mobile/97bb0ca1daa74ae65fd470b1961897275eb91579/images/sprites/followchecked.gif" type="image"></span>
  <input type="hidden" name="scribe_item" value="description=list&amp;id=1875185790&amp;item_type=3">
</form>
</td>

I'd be so appreciated if someone could amend my code! Thank you so much in advance!

Share Improve this question asked Oct 23, 2014 at 18:10 Declan LandDeclan Land 6502 gold badges11 silver badges28 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 5

Using jquery you can use like this...

$('.w-button-mon.w-button-unfollow').click()

both of the class is on same element. So, it should not be any spaces in between the class

Change buttonArray[0].click() to buttonArray[a].click().

The loop index is incorrect

buttonArray[0].click(); <<< mistake in the for loop

buttonArray[a].click(); will do the trick.

发布评论

评论列表(0)

  1. 暂无评论