Don’t start your project with an empty style sheet: there are many great snippets that can make your life easier and speed up web development. We are going to show you some handy snippets that you might find useful for kick-starting your next project.
This is a collection of some basic styles that can come in handy when creating your own style definitions. Learn how to make some useful classes for simple styles and how to apply them to a variety of elements.
How to get client ip address with jQuery $.getJSON(“http://jsonip.appspot.com?callback=?”,function(data){ alert( “Your ip: ” + data.ip); }); How to parse XML with jQuery file.xml: <?xml version=”1.0″ ?> <result> <item> <id>1</id> <title>title1</title> […]
How to hide all children div except a specific one with jQuery? $(‘#target div:not(#exclude)’).hide(); //or $(‘#target’).children().filter(‘:not(#exclude)’).hide(); Detecting when a div’s height changes using jQuery $(‘element’).bind(‘resize’, function(){ alert( ‘Height changed to’ […]
Check if cookies are enabled $(document).ready(function() { var dt = new Date(); dt.setSeconds(dt.getSeconds() + 60); document.cookie = “cookietest=1; expires=” + dt.toGMTString(); var cookiesEnabled = document.cookie.indexOf(“cookietest=”) != -1; if(!cookiesEnabled){ //cookies are […]
How to refresh the src of an image with jQuery? $(imageobj).attr(‘src’, $(imageobj) .attr(‘src’) + ‘?’ + Math.random() ); How to see if an image is loaded or not with jquery […]