Click here to Skip to main content
15,039,244 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: How do I get my input box to persist after clicking Amend? Pin
samflex5-Jul-21 2:41
Membersamflex5-Jul-21 2:41 
GeneralRe: How do I get my input box to persist after clicking Amend? Pin
Richard Deeming5-Jul-21 2:47
mveRichard Deeming5-Jul-21 2:47 
GeneralRe: How do I get my input box to persist after clicking Amend? Pin
samflex5-Jul-21 3:24
Membersamflex5-Jul-21 3:24 
GeneralRe: How do I get my input box to persist after clicking Amend? Pin
Richard Deeming5-Jul-21 3:39
mveRichard Deeming5-Jul-21 3:39 
GeneralRe: How do I get my input box to persist after clicking Amend? Pin
samflex5-Jul-21 3:49
Membersamflex5-Jul-21 3:49 
Questionjs problem Pin
tkshitiz30-Jun-21 22:13
Membertkshitiz30-Jun-21 22:13 
AnswerRe: js problem Pin
Richard MacCutchan30-Jun-21 22:15
mveRichard MacCutchan30-Jun-21 22:15 
QuestionA button at html to trigger an autoplay audio at exact time Pin
Member 1526543827-Jun-21 23:42
MemberMember 1526543827-Jun-21 23:42 
hello! I’m a beginner on coding.

I have an javascript
setInterval(function()
ideally that will auto play a audio at an exact time. Now I want to use a html button to trigger the setInterval(function(). The timer works ok as I’ve tested by using an alert. Please advise if the below codes are ok to do an autoplay audio function?

thanks

the audio in HTML:
<div id="time"></div>
  <audio controls style="display: none;">
     <source src="audio.mp3" type="audio/mpeg" />
 </audio>


the javascript:
setInterval(function() {
    var d = new Date(),
        hours = d.getHours(),
        min = d.getMinutes(),
        sec = d.getSeconds();
    if (hours === 16 && min === 25 && sec === 01) {
        var audio = document.getElementsByTagName('audio')[0]
        audio.play()
        audio.style.display = 'block'
    }
}, 1000)

QuestionRe: A button at html to trigger an autoplay audio at exact time Pin
Richard MacCutchan28-Jun-21 0:06
mveRichard MacCutchan28-Jun-21 0:06 
AnswerRe: A button at html to trigger an autoplay audio at exact time Pin
Member 1526543828-Jun-21 0:11
MemberMember 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
MemberMember 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 
QuestionMessage Closed Pin
20-Jun-21 1:16
MemberMember 1525486220-Jun-21 1:16 
QuestionHow to merge to javascripts to test in console? Pin
ajaszin18-Jun-21 14:52
Memberajaszin18-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 
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 

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.