Created
February 11, 2020 13:58
-
-
Save motsu0/b597064e0a653113cb72bb6742530be7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id="bt-prac">長押しでアラート</button> | |
<p id="op-prac">.</p> | |
<script src="path/to/long-press.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const check_sec = 500; //ミリ秒 | |
const target_element = document.getElementById('bt-prac'); | |
const op_prac = document.getElementById('op-prac'); | |
long_press(target_element, normal_func, long_func, check_sec); | |
function normal_func(){ | |
op_prac.textContent = '通常のクリック or タップ'; | |
} | |
function long_func(){ | |
op_prac.textContent = '.'; | |
window.alert('長押ししました'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment