Click here to Skip to main content
15,867,453 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: A button at html to trigger an autoplay audio at exact time Pin
Member 1526543828-Jun-21 0:11
Member 1526543828-Jun-21 0:11 
GeneralRe: A button at html to trigger an autoplay audio at exact time Pin
Richard MacCutchan28-Jun-21 0:24
mveRichard MacCutchan28-Jun-21 0:24 
AnswerRe: A button at html to trigger an autoplay audio at exact time Pin
Richard Deeming28-Jun-21 4:06
mveRichard Deeming28-Jun-21 4:06 
GeneralRe: A button at html to trigger an autoplay audio at exact time Pin
Member 1526543828-Jun-21 22:11
Member 1526543828-Jun-21 22:11 
GeneralRe: A button at html to trigger an autoplay audio at exact time Pin
Richard Deeming28-Jun-21 22:25
mveRichard Deeming28-Jun-21 22:25 
QuestionHow to merge to javascripts to test in console? Pin
ajaszin18-Jun-21 14:52
ajaszin18-Jun-21 14:52 
AnswerRe: How to merge to javascripts to test in console? Pin
Richard Deeming20-Jun-21 23:45
mveRichard Deeming20-Jun-21 23:45 
GeneralRe: How to merge to javascripts to test in console? Pin
DerekT-P21-Jun-21 9:22
professionalDerekT-P21-Jun-21 9:22 
Where there are multiple CSS selectors, in what order is the result list? (I know, I should experiment and find out!). But for the OP, I suspect this may not be the required solution, since he's wanting all the buttons of one class clicked before the other. Also, it doesn't include the 5 second delay he's after.

So: simply wrap the first block of code in a function ('ClickPolaris') and the second block in another function ('ClickPagination'). To run one, then the other, simply:
JavaScript
ClickPolaris();
ClickPagination();
To implement a five-second delay, you'll need a timer interval:
JavaScript
ClickPolaris();
setTimeout(function() {ClickPolaris();}, 5000);
Of course you can then refine it to use a single parameterised function, called twice with the different class names:
JavaScript
function ClickButtons(classname) {
  var buttons = document.getElementsByClassName(classname);
  for(var i = 0; i <= buttons.length; i++) { 
    buttons[i].click();
  }
}

ClickButtons('Polaris-Button');
setTimeout(function() {ClickButtons('ant-pagination-next');}, 5000);
and further simplify using Richard's suggested syntax:

JavaScript
function ClickButtons(classname) {
document.querySelectorAll(classname).forEach(btn => btn.click());
}

ClickButtons('.Polaris-Button');
setTimeout(function() {ClickButtons('.ant-pagination-next');}, 5000);
Note that in this syntax you need to include the . to indicate you're selecting by class name.
GeneralRe: How to merge to javascripts to test in console? Pin
Richard Deeming21-Jun-21 21:49
mveRichard Deeming21-Jun-21 21:49 
GeneralRe: How to merge to javascripts to test in console? Pin
DerekT-P21-Jun-21 22:50
professionalDerekT-P21-Jun-21 22:50 
QuestionAddEventListener in vanilla Javascript Pin
jkirkerx16-Jun-21 14:52
professionaljkirkerx16-Jun-21 14:52 
AnswerRe: AddEventListener in vanilla Javascript Pin
jkirkerx17-Jun-21 11:16
professionaljkirkerx17-Jun-21 11:16 
AnswerRe: AddEventListener in vanilla Javascript Pin
jkirkerx19-Jun-21 11:24
professionaljkirkerx19-Jun-21 11:24 
AnswerRe: AddEventListener in vanilla Javascript Pin
Richard Deeming20-Jun-21 23:42
mveRichard Deeming20-Jun-21 23:42 
GeneralRe: AddEventListener in vanilla Javascript Pin
jkirkerx21-Jun-21 6:26
professionaljkirkerx21-Jun-21 6:26 
GeneralRe: AddEventListener in vanilla Javascript Pin
Richard Deeming21-Jun-21 6:31
mveRichard Deeming21-Jun-21 6:31 
GeneralRe: AddEventListener in vanilla Javascript Pin
jkirkerx21-Jun-21 6:41
professionaljkirkerx21-Jun-21 6:41 
GeneralRe: AddEventListener in vanilla Javascript Pin
jkirkerx21-Jun-21 6:58
professionaljkirkerx21-Jun-21 6:58 
Questionhow to limit the draggable area in snap.svg? Pin
Member 1269897212-Jun-21 20:45
Member 1269897212-Jun-21 20:45 
QuestionI am getting the following error while trying to run ./watch for my Ember JS application Pin
simpledeveloper1-Jun-21 19:44
simpledeveloper1-Jun-21 19:44 
AnswerRe: I am getting the following error while trying to run ./watch for my Ember JS application Pin
jkirkerx16-Jun-21 14:58
professionaljkirkerx16-Jun-21 14:58 
QuestionHow To Use Dynamic variable in Javascript Pin
pranay kumar 202127-May-21 3:14
pranay kumar 202127-May-21 3:14 
AnswerRe: How To Use Dynamic variable in Javascript Pin
jkirkerx16-Jun-21 15:01
professionaljkirkerx16-Jun-21 15:01 
QuestionHow to deskew a page of pdf document which is loaded through pdf.js Pin
Member 1520321817-May-21 8:58
Member 1520321817-May-21 8:58 
QuestionJavascript Array Wrapper or Class Pin
Member 1510027612-May-21 14:23
Member 1510027612-May-21 14:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.