JavaScript

Scroll Animation

<script type=”text/javascript”> $(‘a[href*=”#”]:not([href=”#”])’).click(function() { if (location.pathname.replace(/^//, ”) == this.pathname.replace(/^//, ”) && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $(‘[name=’ + this.hash.slice(1) + ‘]’); if (target.length) { $(‘html, body’).animate({ scrollTop: target.offset().top }, 1000); return false; } } }); </script>

Go to Top

<style type=”text/css”> .go-top { position: fixed; bottom: 2em; left: 2em; text-decoration: none; color: white; background-color: rgba(0, 0, 0, 0.3); font-size: 12px; padding: 1em; display: none; } .go-top:hover { background-color: rgba(0, 0, 0, 0.6); } </style> <!– gototop –> <script type=”text/javascript”> $(document).ready(function () { $(‘[data-toggle=”offcanvas”]’).click(function () { $(‘.row-offcanvas’).toggleClass(‘active’) }); }); $(document).ready(function() { // Show or hide …

Go to Top Selengkapnya »

Select with onChange

<select onChange=”window.location.href=this.value”> <option value=”www.google.com”>A</option> <option value=”www.aol.com”>B</option> </select>

Custom Google Translate

<script type=”text/javascript”> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: ‘en’, includedLanguages: ‘en,ms’, layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, ‘google_translate_element’); } </script> <script type=”text/javascript” src=”//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit”></script> <div id=”google_translate_element”></div> <style type=”text/css”> .goog-te-gadget-simple{ border: 0; border-radius: 4px; padding: 4px 8px !important; color: white; height: auto; font-size: 1.2em; background-color: #0d47a1 !important;border:0px !important;margin-top: 10px !important;color: #fff !important; } .goog-te-menu-value{ color: #fff !important; } .goog-te-gadget-icon{ display: none; } …

Custom Google Translate Selengkapnya »

JQuery no Conflict

<script type=”text/javascript”> var newJQuery = jQuery.noConflict(true), oldJQuery = jQuery; (function ($) { // code that needs 1.4.2 goes here }(newJQuery)); (function ($) { // code that needs 1.2.6 goes here }(oldJQuery)); // code that needs oldJQuery and newJQuery can go here </script>

Google Recaptcha Required

if($(“#captha”).val() == ”){ error = true; message += ‘Captchan’; } $(“form”).submit(function(event) { var recaptcha = $(“#g-recaptcha-response”).val(); if (recaptcha === “”) { event.preventDefault(); alert(“Please check the recaptcha”); } });

×