How to have these buttons clicked automatically at an interval jquery -
<button class="sitebutton bigbutton" onclick="setcategory('123456');"><span>save</span></button> <button class="sitebutton bigbutton" onclick="setcategory('123455');"><span>save</span></button> <button class="sitebutton bigbutton" onclick="setcategory('123454');"><span>save</span></button> <button class="sitebutton bigbutton" onclick="setcategory('123453');"><span>save</span></button>
how click on save button using jquery after interval maybe of 0.5 seconds
try using setinterval()
var buttons = $('.sitebutton'); var len = buttons.length, = 0; var interv = setinterval(function() { buttons.eq(i++).click(); if (i == len) clearinterval(interv); },1000); function setcategory(v) { alert(v); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <button class="sitebutton bigbutton" onclick="setcategory('123456');"><span>save</span> </button> <button class="sitebutton bigbutton" onclick="setcategory('123455');"><span>save</span> </button> <button class="sitebutton bigbutton" onclick="setcategory('123454');"><span>save</span> </button> <button class="sitebutton bigbutton" onclick="setcategory('123453');"><span>save</span> </button>
Comments
Post a Comment