Javascript Audio Play on click

Try the below code snippet <!doctype html> <html> <head> <title>Audio</title> </head> <body> <script> function play() { var audio = document.getElementById(“audio”); audio.play(); } </script> <input type=”button” value=”PLAY” onclick=”play()”> <audio id=”audio” src=”https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3″></audio> </body> </html>

CSS Animation onClick

Are you sure you only display your page on webkit? Here is the code, passed on safari. The image (id=’img’) will rotate after button click. function ani() { document.getElementById(‘img’).className=”classname”; } .classname { -webkit-animation-name: cssAnimation; -webkit-animation-duration: 3s; -webkit-animation-iteration-count: 1; -webkit-animation-timing-function: ease; -webkit-animation-fill-mode: forwards; } @-webkit-keyframes cssAnimation { from { -webkit-transform: rotate(0deg) scale(1) skew(0deg) translate(100px); } to … Read more

Click toggle with jQuery

This is easily done by flipping the current ‘checked’ state of the checkbox upon each click. Examples: $(“.offer”).on(“click”, function () { var $checkbox = $(this).find(‘:checkbox’); $checkbox.attr(‘checked’, !$checkbox.attr(‘checked’)); }); or: $(“.offer”).on(“click”, function () { var $checkbox = $(this).find(‘:checkbox’); $checkbox.attr(‘checked’, !$checkbox.is(‘:checked’)); }); or, by directly manipulating the DOM ‘checked’ property (i.e. not using attr() to fetch the … Read more

How to track a Google Adwords conversion onclick?

Don’t know if you’ve already found it… I mention it anyway for future surfers… I was looking for the same, and found this piece of code : <script type=”text/javascript”> function trackConv(google_conversion_id, google_conversion_label) { var image = new Image(1, 1); image.src = “//www.googleadservices.com/pagead/conversion/” + google_conversion_id + “/?label=” + google_conversion_label + “&script=0”; } </script> Then for links … Read more

Simulating a click in jQuery/JavaScript on a link

You can use the the click function to trigger the click event on the selected element. Example: $( ‘selector for your link’ ).click (); You can learn about various selectors in jQuery’s documentation. EDIT: like the commenters below have said; this only works on events attached with jQuery, inline or in the style of “element.onclick”. … Read more

TabLayout without using ViewPager

I found addOnTabSelectedListener: tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { if(tabLayout.getSelectedTabPosition() == 0){ Toast.makeText(MainActivity.this, “Tab ” + tabLayout.getSelectedTabPosition(), Toast.LENGTH_LONG).show(); }else if(tabLayout.getSelectedTabPosition() == 1){ Toast.makeText(MainActivity.this, “Tab ” + tabLayout.getSelectedTabPosition(), Toast.LENGTH_LONG).show(); }else if(tabLayout.getSelectedTabPosition() == 2){ Toast.makeText(MainActivity.this, “Tab ” + tabLayout.getSelectedTabPosition(), Toast.LENGTH_LONG).show(); }else if(tabLayout.getSelectedTabPosition() == 3){ Toast.makeText(MainActivity.this, “Tab ” + tabLayout.getSelectedTabPosition(), Toast.LENGTH_LONG).show(); }else if(tabLayout.getSelectedTabPosition() == 4){ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)