Skip to content

Commit

Permalink
[#3] ボタンのトグル処理を実装
Browse files Browse the repository at this point in the history
  • Loading branch information
前原夏樹 committed Aug 23, 2018
1 parent 4b718a7 commit 44b03c4
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions app/assets/javascripts/timer.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
document.addEventListener('DOMContentLoaded', function() {

document.getElementById('btn').addEventListener('click', function() {
toggleBtnFunction();
})

document.getElementsByClassName('start-timer').addEventListener('click', function() {
startTimer();
})

document.getElementsByClassName('stop-timer').addEventListener('click', function() {
stopTimer();
})
}
)

function toggleBtnFunction() {
var button = document.getElementById('btn');
if(button.value == 'Start') {
if(button.value == 'Start' || button.value == 'ReStart') {
button.value = 'Stop';
button.className = 'stop-timer';
startTimer();
} else if(button.value == 'Stop') {
button.value = 'Start';
stopTimer();
button.value = 'ReStart';
button.className = 'start-timer';
}
}

function startTimer() {

}

function stopTimer() {

}

0 comments on commit 44b03c4

Please sign in to comment.