Categories
Friends
Links
Category Archives: jQuery
How to Show/Hide a div based on day of the week with jQuery
JavaScritpt <script type="text/javascript"> $(document).ready(function() { today=new Date() thisDay=today.getDay() $("#sunday").hide(); $("#monday").hide(); $("#tuesday").hide(); [...]
Also posted in JavaScript Tagged date, day of week, getDay, hide, JavaScript, jQuery, show Leave a comment
How to set more than one event/option – jQuery Accordion
In The example below we set the mouseover event, auto height option as false and starts with the 3rd selector opened. (The index is a zero-indexed number to match the position of the header) JavaScript <script type="text/javascript"> $(function() { $(‘.subnav-rhs’).accordion({event: ‘mouseover’, [...]
Posted in jQuery Leave a comment
Character Count with jQuery
jQuery $(‘textarea’).each(function(){ // get current number of characters var length = $(this).val().length; // get current number of words //var length = $(this).val().split(/\b[\s,\.-:;]*/).length; // update characters $(this).parent().find(‘.counter’).html( 4000 – length + ‘ characters left’); // bind on key up event [...]
How to Scroll to the Top Smoothly with jQuery
jQuery $(document).ready(function() { $(‘.backtotop’).click(function(){ $(‘html, body’).animate({scrollTop:0}, ‘slow’); }); });
How to Scroll to Anchor Links Smoothly with jQuery
jQuery $.fn.scroller = function() { var speed = ‘slow’; // Choose default speed $(this).each(function() { $(this).bind(‘click’, function() { var target = $(this).attr(‘href’); // Get scroll target [...]
Posted in jQuery Tagged anchor, jQuery, link, link same page, scroll, scroller, smooth Leave a comment
Fade in Fade out with jQuery
jQuery q1 = { init: function() { $("table.appTranslation").click(function() { $(this).fadeOut(‘slow’, function() { $(this).html("Text to [...]
Posted in jQuery Leave a comment
Preloading Images with jQuery
jQuery jQuery.preloadImages = function() { for(var i = 0; i<arguments.length; i++) { jQuery("<img>").attr("src", arguments[i]); } }; // use like $.preloadImages("image0001.jpg", "/path/to/image0002.jpg", "some/image0003.jpg");
How to display fields using select drop down and jQuery