Make a vibrating effect when there is a click action

Updated on July 08, 2022
create a vibrating effect when there is a click action

Hello all on this occasion I will share how to make a vibrating effect when there is a click action on our blog want it to be a link image button and whatever it is we are free to choose it.

To try the demo please click one of the icons on this blog via mobile or click the demo button below.

please copy the script below and place it on top of the </body> or < code! --</body>--></body>

<script>/*<![CDATA[*/
var getar = document.querySelectorAll('.getar');
for (var i = 0; i < getar.length; i++) {
 var getarr = getar[i];
 getarr.addEventListener('click', function() {
 navigator.vibrate(40)
 });
}
/*]]>*/</script>

How to Use

how to use you just call the vibrate class on the html element that you want to create a vibrating effect when there is a click action, it can be in the form of a link button to any image that is free.

<!-- contoh -->
<button class='getar'>klik di sini</button>
<!-- atau -->
<a class='getar' href='#'>ini tautan aktif</a>
<!-- atau -->
<div class='getar'>ini div</div>

ok so that's how to make a vibrating effect when there is a click action that I can share this time hopefully useful and thank you for visiting.

Source:https://www.wendycode.com/2022/06/membuat-efek-getar-saat-ada-aksi-klik.html
Gửi link bài viết sang điện thoại:
Share this: pinterest