How to Make Images Progressive (Allow Download in multiple passes) - Simplest method explained!


Requirements :

  • Adobe Photoshop

Steps to make an image progressive.


Open Photoshop.

Press CTRL+O to open image that you want to make progressive.

Select "save for web" option from file menu OR press Alt+Shift+Ctrl+S.



A new window will appear.

Select tab "Optimized" at the top left side of the window.


Now, at the right side of the window, you can configure the output image's settings.

Select output format.(JPG is better).
Set Quality. (60 is better) reducing quality from 100% will also reduce image size.
Set blur, if you want to blur a little.

Click on save.

Now if you upload the image and download it, it will be downloaded in multiple passes.

Read Article →

Best way to hide Email address in your website or blog from Spam bots - Google's mailhide



If you have a website or blog, it is necessary to put your email there to let visitors to contact you.
may be only in contact page or in every page.
But what if some bad bots searching websites for mail addresses in blogs or websites crawled into your website? yes. there is the problem that they will send you number of advt emails to your inbox.
if your mail server doesn't have an effective spam filter, things will get worse than that.
 you will be getting numerous mails each day that make your job difficult.

So, Whats the effective way to prevent spam bots to get your email address but to let your real visitors grab your email address so that they can contact you?

GOOGLE, the unstoppable king has the answer.
To hide your email address from bots,and let your visitors grab it after a simple captcha test, Google has a service named "MAIL HIDE"
Go make it today.
Go below address and get the code from there and put it whereever you want visitors to see the link to your mail address.

http://www.google.com/recaptcha/mailhide/


There you can see a text field  labled protect your mail.
Type your email address in it

You will be taken to next page after you click Protect it button.

There you can see two code blocks for you.
One is the text field which contain a URL to your protected email. you can make a link to that URL in your web page. shown in the figure below.



http://www.google.com/recaptcha/mailhide/d?k=01zI57-KPkSDVJEtubLfJaMw==&c=4GL32YEpIYeIqgdJWlqemLdYlQCJ7ElRa4KN3nHJOo8=


Next one is the HTML code we can put in our webpage, where visitor can click on the link and it will take them to your mail,protected with captcha


your<a href="http://www.google.com/recaptcha/mailhide/d?k=01zI57-KPkSDVJEtubLfJaMw==&amp;c=4GL32YEpIYeIqgdJWlqemLdYlQCJ7ElRa4KN3nHJOo8=" onclick="window.open('http://www.google.com/recaptcha/mailhide/d?k\07501zI57-KPkSDVJEtubLfJaMw\75\75\46c\0754GL32YEpIYeIqgdJWlqemLdYlQCJ7ElRa4KN3nHJOo8\075', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;" title="Reveal this e-mail address">...</a>@domain.com

Copy paste that code you see  into your web page where you want to display your email to visitors.

Below is screenshots of How it seen after implementation and how does it work.

User Sees a "you..@domain.com" on contact area.



User clicks on that . It will pop up a window,asking user to enter a captcha.


After filling and clicking on "reveal email address" button, it will show user the real email.




There are many methods out there, but i trust this one most. because it is provided by GOOGLE. whats more than that ;)

Read Article →

How to reset CSS for only a DIV or any other html element -Simple solution!

The aim of a CSS reset is to prevent inconsistency of elements that is nested to other elements,by reseting the height,width,margin,etc styles to the default ones.
there are many ways to reset style of an elemet to the specific one.
one solution is to add a !important after the style attribute. like h1{font-size:25px!important;}
and another is to overwrite each element style to the default one.
and another is to use an css reset stylesheet to reset.
Finest solution is to use a css reset tool. Below is Aslamise Css reset script. You may have to tweak a little if you find anything that doesnt suits your needs.
.aslamise-css-reset html{color:#000;background:#FFF;}.aslamise-css-reset body,.aslamise-css-reset div,.aslamise-css-reset dl,.aslamise-css-reset dt,.aslamise-css-reset dd,.aslamise-css-reset ul,.aslamise-css-reset ol,.aslamise-css-reset li,.aslamise-css-reset h1,.aslamise-css-reset h2,.aslamise-css-reset h3,.aslamise-css-reset h4,.aslamise-css-reset h5,.aslamise-css-reset h6,.aslamise-css-reset pre,.aslamise-css-reset code,.aslamise-css-reset form,.aslamise-css-reset fieldset,.aslamise-css-reset legend,.aslamise-css-reset input,.aslamise-css-reset textarea,.aslamise-css-reset p,.aslamise-css-reset blockquote,.aslamise-css-reset th,.aslamise-css-reset td{margin:0;padding:0}.aslamise-css-reset table{border-collapse:collapse;border-spacing:0}.aslamise-css-reset fieldset,.aslamise-css-reset img{border:0}.aslamise-css-reset address,.aslamise-css-reset caption,.aslamise-css-reset cite,.aslamise-css-reset code,.aslamise-css-reset dfn,.aslamise-css-reset em,.aslamise-css-reset strong,.aslamise-css-reset th,.aslamise-css-reset var{font-style:normal;font-weight:normal}.aslamise-css-reset ol,.aslamise-css-reset ul{list-style:none}.aslamise-css-reset li{list-style:none}.aslamise-css-reset caption,.aslamise-css-reset th{text-align:left}.aslamise-css-reset h1,.aslamise-css-reset h2,.aslamise-css-reset h3,.aslamise-css-reset h4,.aslamise-css-reset h5,.aslamise-css-reset h6{font-size:100%;font-weight:normal}.aslamise-css-reset q:before,.aslamise-css-reset q:after{content:''}.aslamise-css-reset abbr,.aslamise-css-reset acronym{border:0;font-variant:normal}.aslamise-css-reset sup{vertical-align:text-top}.aslamise-css-reset sub{vertical-align:text-bottom}.aslamise-css-reset input,.aslamise-css-reset textarea,.aslamise-css-reset select{font-family:inherit;font-size:inherit;font-weight:inherit}.aslamise-css-reset input,.aslamise-css-reset textarea,.aslamise-css-reset select{*font-size:100%}.aslamise-css-reset legend{color:#000}.aslamise-css-reset *{background:none;color:black;} Lets take a look at it.
  • This is a ul li block where no class assigned

  • This is a ul li block where aslamise-css-reset assigned


So , lets see how to use this css reset in your page. Copy and paste above css reset code in your stylesheet at the bottom of stylesheet. Then add class "aslamise-css-reset" to the element where you want to reset your css. Example: <ul class='aslamise-css-reset'><li>This is a ul li block where aslamise-css-reset assigned</li></ul> If you want to see another example, see previous post's "demo", where aslamise-css-reset class enabled!.

Read Article →

Simple Tutorial: How to use jQuery&CSS to show or hide tab contents without page jump

While making elements in your website or blog 'beautiful and easy to navigate', you will have to adjust elements in an order.
 Here we going to lean how to set up a navigation system which shows single section's content at a time as per user condition and where a group of multiple sections exist,without page jump.
just like the example below.


Contents in tab 1 section
Contents in tab 2 section
Contents in tab 3 section


So here we go. Hope you have understanding of jQuery, CSS,and HTML.
 First, lets make our navigation menu for calling tabs.
  <div> <ul class="nav nav-tabs"> <li class="active"> <a href="#tab1">tab 1</a> </li> <li> <a href="#tab2">tab 2</a> </li> <li> <a href="#tab3">tab 3</a> </li> </ul> </div> 

Then next to that, lets setup our sections where each section will have id like tab1,tab2,tab3 in this order.
  <section id='tab1' class="tab-content active"> Contents in tab 1 section </section> <section id='tab2' class="tab-content hide"> Contents in tab 2 section </section> <section id='tab3' class="tab-content hide"> Contents in tab 3 section </section> 

Now, lets style our navigation menu and sections with CSS
  <style type='text/css'> .nav { margin-bottom: 18px; margin-left: 0; list-style: none; } .nav > li > a { display: block; } .nav-tabs{ *zoom: 1; } .nav-tabs:before, .nav-tabs:after { display: table; content: ""; } .nav-tabs:after { clear: both; } .nav-tabs > li { float: left; } .nav-tabs > li > a { padding-right: 12px; padding-left: 12px; margin-right: 2px; line-height: 14px; } .nav-tabs { border-bottom: 1px solid #ddd; } .nav-tabs > li { margin-bottom: -1px; } .nav-tabs > li > a { padding-top: 8px; padding-bottom: 8px; line-height: 18px; border: 1px solid transparent; -webkit-border-radius: 4px 4px 0 0; -moz-border-radius: 4px 4px 0 0; border-radius: 4px 4px 0 0; } .nav-tabs > li > a:hover { border-color: #eeeeee #eeeeee #dddddd; } .nav-tabs > .active > a, .nav-tabs > .active > a:hover { color: #555555; cursor: default; background-color: #ffffff; border: 1px solid #ddd; border-bottom-color: transparent; } li { line-height: 18px; } .tab-content.active{ display: block; } .tab-content.hide{ display: none; } </style> 

Next, we need to Call jQuery, if you have already called jQuery in your document, then skip this step.
  <script type='text/javascript' src='//code.jquery.com/jquery-1.8.3.js'></script> 

Now, the last step, We have to display our tab2 section when we click on it. same time we have to hide the other tabs. 
 Our jQuery code is below

  <script type='text/javascript'> $(document).ready(function() { $('.nav-tabs > li > a').click(function(event){ event.preventDefault();//stop browser to take action for clicked anchor //get displaying tab content jQuery selector var active_tab_selector = $('.nav-tabs > li.active > a').attr('href'); //find actived navigation and remove 'active' css var actived_nav = $('.nav-tabs > li.active'); actived_nav.removeClass('active'); //add 'active' css into clicked navigation $(this).parents('li').addClass('active'); //hide displaying tab content $(active_tab_selector).removeClass('active'); $(active_tab_selector).addClass('hide'); //show target tab content var target_tab_selector = $(this).attr('href'); $(target_tab_selector).removeClass('hide'); $(target_tab_selector).addClass('active'); }); }); </script> 

We are done! Go play with it. 
 Here is a sample demo you can play with ! 

http://jsfiddle.net/Aslamise/Qt7jx/

Read Article →

Beautiful jQuery tooltip



  • Tool-tips are title of the element which displays when a user hover on same element.
  • There are many plugins available to make tool-tips more beautiful but i prefer this one because it can be customized as we wish and it is compatible with almost all major web browsers.
  • What tool-tip plugins do is , Calling the title attribute's value and displays it on the customized html design.
  • jQuery tooltipster is highly customization enabled plugin. in this article, i have also covered something that will be helpful to change the direction of tool-tip arrow just by assigning class than the default one's.
  • we can use tool-tip on top the element, right side of the element,left side of the element,top left side of the element,top right side of the element,or bottom,bottom right or bottom left of the element.
  • all you have to do is just add this to your website or blog and to assign the needed class to element which has a title attribute with some value in it.

  • Here is a live demo that you can understand how this plugin works.
     To add this beautiful jQuery tool-tip plugin to your blog or website, follow instructions below.
    1Call style-sheet or internal style block between <head></head> tags. <link rel="stylesheet" type="text/css" href="path-to/css/tooltipster.css" /> OR   <style type='text/css'> .tooltipster-chocolate { background-color: #7f5d3c; border: 2px solid #5c3d1f; color: #fafaeb; font-family: Arial, sans-serif; font-size: 12px; line-height: 12px; position: absolute; padding: 10px; border-radius: 4px; text-align: center; z-index: 9999999; pointer-events: none; width: auto; overflow: visible; } .tooltipster-chocolate .tooltip-arrow { text-shadow: 0px 2px 0px #654728, 1px 1px 0px #654728, -1px 1px 0px #654728; } .tooltipster-clean-cut { background-color: #f9f9f9; border: 1px solid #dadada; box-shadow: inset 0px 1px 0px #fff; color: #595959; font-family: Arial, sans-serif; font-size: 12px; line-height: 12px; position: absolute; padding: 10px; border-radius: 4px; text-align: center; z-index: 9999999; pointer-events: none; width: auto; overflow: visible; } .tooltipster-clean-cut .tooltip-arrow { text-shadow: 0px 2px 0px #dadada, 0px 1px 0px #dadada; } .tooltipster-smoke { background-color: #111; border: 2px solid black; border-radius: 6px; box-shadow: 5px 5px 7px #444; opacity: 0.7; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70); color: white; font-family: Arial, sans-serif; font-weight: bold; font-size: 12px; line-height: 12px; position: absolute; padding: 10px; text-align: center; z-index: 9999999; pointer-events: none; width: auto; overflow: visible; } .tooltipster-smoke .tooltip-arrow { text-shadow: 5px 5px 7px #444; } /* This is the default styling for all Tooltipsters: */ .tooltip-message { background: #000; /* <- for IE */ background: rgba(0,0,0,0.9); color: #fff; font-family: Arial, sans-serif; font-size: 12px; line-height: 12px; position: absolute; padding: 10px; border-radius: 2px; text-align: center; z-index: 9999999; pointer-events: none; width: auto; overflow: visible; word-wrap:break-word; } /* When you want to create a second class for your Tooltipster messages, copy (or modify) this template and add your style to it. Don't forget to refer to it in your Tooltipster settings (tooltipClass: '.my-custom-theme') */ .my-custom-theme { position: absolute; text-align: center; z-index: 9999999; pointer-events: none; width: auto; /* Start styling here... */ } /* Add a slight border radius to all images inside the Tooltipsters */ .tooltip-message img { border-radius: 2px; } /* These next classes handle the styles for the little arrow attached to the tooltip. If you need to change the color of the arrow to match a custom Tooltipster theme, set it in your Tooltipster settings (arrowColor: '#yourcolor') */ .tooltip-arrow { display: block; text-align: center; font-size: 12px; line-height: 12px; width: 100%; height: 5px; position: absolute; left: 0px; z-index: -1; } .tooltip-arrow-top { bottom: -3px; margin: 0 auto; text-align: center; } .tooltip-arrow-top-right { bottom: -3px; margin-left: -10px; text-align: right; } .tooltip-arrow-top-left { bottom: -3px; margin-left: 10px; text-align: left; } .tooltip-arrow-bottom { top: -10px; margin: 0 auto; text-align: center; } .tooltip-arrow-bottom-right { top: -10px; margin-left: -10px; text-align: right; } .tooltip-arrow-bottom-left { top: -10px; margin-left: 10px; text-align: left; } .tooltip-arrow-left { top: 0px; right: -18px; margin: 0 auto; text-align: right; } .tooltip-arrow-right { top: 0px; left: -8px; margin: 0 auto; text-align: left; } /* Some styling to enable the slide animation */ .tooltip-slide { height: 0px; position: absolute; width: auto; z-index: 9999999; overflow: hidden; } </style> 
    2Add jQuery. if you have already called jQuery before, skip this step
      &lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.8.0.min.js&quot;&gt;&lt;/script&gt; 
    3 Call External jQuery plugin script or insert code block between <head></head> tags.
    <script type="text/javascript" src="http://aslamise.googlecode.com/files/jquery.tooltipster.min.js"></script>
    OR
    <script type='text/javascript'>//<![CDATA[ $(window).load(function(){ (function( $ ) { $.fn.tooltipster = function( options ) { var settings = $.extend({ animation: 'fade', arrow: true, arrowColor: '', delay: 200, fixedWidth: 0, followMouse: false, offsetX: 0, offsetY: 0, overrideText: '', position: 'top', speed: 100, timer: 0, tooltipTheme: '.tooltip-message' }, options); function animateOut(tooltipToKill) { if(settings.animation == 'slide') { $(tooltipToKill).slideUp(settings.speed, function() { $(tooltipToKill).remove(); $("body").css("overflow-x", "auto"); }); } else { $(tooltipToKill).fadeOut(settings.speed, function() { $(tooltipToKill).remove(); $("body").css("overflow-x", "auto"); }); } } return this.hover(function() { if ($(settings.tooltipTheme).not('.tooltip-kill').length == 1) { animateOut($(settings.tooltipTheme).not('.tooltip-kill')); $(settings.tooltipTheme).not('.tooltip-kill').addClass('tooltip-kill'); } $("body").css("overflow-x", "hidden"); var tooltip_text = $(this).attr('title'); $(this).attr('title', ''); $(this).data('title', tooltip_text); if($.trim(settings.overrideText).length > 0) { var tooltip_text = settings.overrideText; } if(settings.fixedWidth > 0) { var fixedWidth = ' style="width:'+ settings.fixedWidth +'px;"'; } else { var fixedWidth = ''; } $('<div class="'+ settings.tooltipTheme.replace('.','') +'"'+ fixedWidth +'><div class="tooltip-message-content">'+tooltip_text+'</div></div>').appendTo('body').hide(); if (settings.followMouse == false) { var window_width = $(window).width(); var container_width = $(this).outerWidth(false); var container_height = $(this).outerHeight(false); var tooltip_width = $(settings.tooltipTheme).not('.tooltip-kill').outerWidth(false); var tooltip_height = $(settings.tooltipTheme).not('.tooltip-kill').outerHeight(false); var offset = $(this).offset(); if(settings.fixedWidth == 0) { $(settings.tooltipTheme).not('.tooltip-kill').css({ 'width': tooltip_width + 'px', 'padding-left': '0px', 'padding-right': '0px' }); } function dont_go_off_screen() { var window_left = $(window).scrollLeft(); if((my_left - window_left) < 0) { var arrow_reposition = my_left - window_left; my_left = window_left; $(settings.tooltipTheme).not('.tooltip-kill').data('arrow-reposition', arrow_reposition); } if (((my_left + tooltip_width) - window_left) > window_width) { var arrow_reposition = my_left - ((window_width + window_left) - tooltip_width); my_left = (window_width + window_left) - tooltip_width; $(settings.tooltipTheme).not('.tooltip-kill').data('arrow-reposition', arrow_reposition); } } if(settings.position == 'top') { var left_difference = (offset.left + tooltip_width) - (offset.left + $(this).outerWidth(false)); var my_left = (offset.left + settings.offsetX) - (left_difference / 2); var my_top = (offset.top - tooltip_height) - settings.offsetY - 10; dont_go_off_screen(); if((offset.top - tooltip_height - settings.offsetY - 11) < 0) { var my_top = 0; } } if(settings.position == 'top-left') { var my_left = offset.left + settings.offsetX; var my_top = (offset.top - tooltip_height) - settings.offsetY - 10; dont_go_off_screen(); } if(settings.position == 'top-right') { var my_left = (offset.left + container_width + settings.offsetX) - tooltip_width; var my_top = (offset.top - tooltip_height) - settings.offsetY - 10; dont_go_off_screen(); } if(settings.position == 'bottom') { var left_difference = (offset.left + tooltip_width + settings.offsetX) - (offset.left + $(this).outerWidth(false)); var my_left = offset.left - (left_difference / 2); var my_top = (offset.top + container_height) + settings.offsetY + 10; dont_go_off_screen(); } if(settings.position == 'bottom-left') { var my_left = offset.left + settings.offsetX; var my_top = (offset.top + container_height) + settings.offsetY + 10; dont_go_off_screen(); } if(settings.position == 'bottom-right') { var my_left = (offset.left + container_width + settings.offsetX) - tooltip_width; var my_top = (offset.top + container_height) + settings.offsetY + 10; dont_go_off_screen(); } if(settings.position == 'left') { var my_left = offset.left - settings.offsetX - tooltip_width - 10; var my_left_mirror = offset.left + settings.offsetX + container_width + 10; var top_difference = (offset.top + tooltip_height + settings.offsetY) - (offset.top + $(this).outerHeight(false)); var my_top = offset.top - (top_difference / 2); if((my_left < 0) && ((my_left_mirror + tooltip_width) > window_width)) { my_left = my_left + tooltip_width; } if(my_left < 0) { var my_left = offset.left + settings.offsetX + container_width + 10; $(settings.tooltipTheme).not('.tooltip-kill').data('arrow-reposition', 'left'); } } if(settings.position == 'right') { var my_left = offset.left + settings.offsetX + container_width + 10; var my_left_mirror = offset.left - settings.offsetX - tooltip_width - 10; var top_difference = (offset.top + tooltip_height + settings.offsetY) - (offset.top + $(this).outerHeight(false)); var my_top = offset.top - (top_difference / 2); if(((my_left + tooltip_width) > window_width) && (my_left_mirror < 0)) { my_left = window_width - tooltip_width; } if((my_left + tooltip_width) > window_width) { my_left = offset.left - settings.offsetX - tooltip_width - 10; $(settings.tooltipTheme).not('.tooltip-kill').data('arrow-reposition', 'right'); } } } if (settings.followMouse == true) { var tooltip_width = $(settings.tooltipTheme).not('.tooltip-kill').outerWidth(false); var tooltip_height = $(settings.tooltipTheme).not('.tooltip-kill').outerHeight(false); var tooltip_content = $(settings.tooltipTheme).not('.tooltip-kill').find('.tooltip-message-content').html(); $(this).mousemove(function(e){ $(settings.tooltipTheme).not('.tooltip-kill').find('.tooltip-message-content').html('').html(tooltip_content); var tooltip_height = $(settings.tooltipTheme).not('.tooltip-kill').outerHeight(false); if(settings.position == 'top') { $(settings.tooltipTheme).not('.tooltip-kill').css({ 'left': ((e.pageX - 1) - (tooltip_width / 2) + settings.offsetX) + 'px', 'top': ((e.pageY - tooltip_height - 2) - settings.offsetY - 10) + 'px' }); } if(settings.position == 'top-right') { $(settings.tooltipTheme).not('.tooltip-kill').css({ 'left': e.pageX - 8 + settings.offsetX + 'px', 'top': ((e.pageY - tooltip_height - 2) - settings.offsetY - 10) + 'px' }); } if(settings.position == 'top-left') { $(settings.tooltipTheme).not('.tooltip-kill').css({ 'left': (e.pageX - tooltip_width + settings.offsetX) + 7 + 'px', 'top': ((e.pageY - tooltip_height - 2) - settings.offsetY - 10) + 'px' }); } if(settings.position == 'bottom') { $(settings.tooltipTheme).not('.tooltip-kill').css({ 'left': (e.pageX - (tooltip_width / 2) + settings.offsetX - 1) + 'px', 'top': (e.pageY + 15 + settings.offsetY + 10) + 'px' }); } if(settings.position == 'bottom-right') { $(settings.tooltipTheme).not('.tooltip-kill').css({ 'left': e.pageX - 2 + settings.offsetX + 'px', 'top': (e.pageY + 15 + settings.offsetY + 10) + 'px' }); } if(settings.position == 'bottom-left') { $(settings.tooltipTheme).not('.tooltip-kill').css({ 'left': (e.pageX - tooltip_width + settings.offsetX) + 12 + 'px', 'top': (e.pageY + 15 + settings.offsetY + 10) + 'px' }); } }); } if (settings.arrow == true){ var arrow_class = 'tooltip-arrow-' + settings.position; if (settings.followMouse == true) { if(arrow_class.search('right') > 0) { var temp_arrow_class = arrow_class; arrow_class = temp_arrow_class.replace('right', 'left'); } else { var temp_arrow_class = arrow_class; arrow_class = temp_arrow_class.replace('left', 'right'); } } if(arrow_class == 'tooltip-arrow-right') { var arrow_type = '◀'; var arrow_vertical = 'top:' + ((tooltip_height / 2) - 5) + 'px'; } if(arrow_class == 'tooltip-arrow-left') { var arrow_type = '▶'; var arrow_vertical = 'top:' + ((tooltip_height / 2) - 4) + 'px'; } if(arrow_class.search('top') > 0) { var arrow_type = '▼'; } if(arrow_class.search('bottom') > 0) { var arrow_type = '▲'; } if(settings.arrowColor.length < 1) { var arrow_color = $(settings.tooltipTheme).not('.tooltip-kill').css('background-color'); } else { var arrow_color = settings.arrowColor; } var arrow_reposition = $(settings.tooltipTheme).not('.tooltip-kill').data('arrow-reposition'); if (!arrow_reposition) { arrow_reposition = ''; } else if (arrow_reposition == 'left') { arrow_class = 'tooltip-arrow-right'; arrow_type = '◀'; arrow_reposition = ''; } else if (arrow_reposition == 'right') { arrow_class = 'tooltip-arrow-left'; arrow_type = '▶'; arrow_reposition = ''; } else { arrow_reposition = 'left:'+ arrow_reposition +'px;'; } var arrow = '<div class="'+ arrow_class +' tooltip-arrow" style="color:'+ arrow_color +'; width:'+ tooltip_width +'px; display:none; '+ arrow_reposition +' '+ arrow_vertical +'">'+ arrow_type +'</div>'; } else { var arrow = ''; } $(settings.tooltipTheme).not('.tooltip-kill').css({'top': my_top+'px', 'left': my_left+'px'}).append(arrow); if(settings.animation == 'slide') { $(settings.tooltipTheme).not('.tooltip-kill').delay(settings.delay).slideDown(settings.speed, function() { $('.tooltip-arrow').fadeIn(settings.speed); }); if(settings.timer > 0) { $(settings.tooltipTheme).not('.tooltip-kill').delay(settings.timer).slideUp(settings.speed); } } else { $('.tooltip-arrow').show(); $(settings.tooltipTheme).not('.tooltip-kill').delay(settings.delay).fadeIn(settings.speed); if(settings.timer > 0) { $(settings.tooltipTheme).not('.tooltip-kill').delay(settings.timer).fadeOut(settings.speed); } } }, function() { $(settings.tooltipTheme).not('.tooltip-kill').clearQueue(); tooltip_text = $(this).data('title'); $(this).attr('title', tooltip_text); $(settings.tooltipTheme).addClass('tooltip-kill'); animateOut('.tooltip-kill'); }); } })( jQuery ); $(document).ready(function() { $('.tpt').tooltipster({fixedWidth: 200,position: 'top'}); $('.tpb').tooltipster({fixedWidth: 200,position: 'bottom'}); $('.tpl').tooltipster({fixedWidth: 200,position: 'left'}); $('.tpr').tooltipster({fixedWidth: 200,position: 'right'}); $('.tptl').tooltipster({fixedWidth: 200,position: 'top-left'}); $('.tptr').tooltipster({fixedWidth: 200,position: 'top-right'}); $('.tpbl').tooltipster({fixedWidth: 200,position: 'bottom-left'}); $('.tpbr').tooltipster({fixedWidth: 200,position: 'bottom-right'}); }); });//]]> </script>
    4Now , lets test it.
    Paste this anywhere in your blog or website's source code.
     <a class='tpb' title='my awesome tooltip'>Tooltip</a>
    
     (Please note that if you are using original tooltipster Code for this,then the classes always be 'tooltip',and if you are using script above,then it can be tpt,tpb,tpl,tpr,tptl,tptr,tpbl,tpbr- as you can specify the direction of the tooltip )
     If everything works ,please be kind to tell it in comments, else start a discussion and find your solution.
     Or you can go to tooltipster's project page and follow their instructions. they have made an easy guide for beginners
    http://calebjacob.com/tooltipster/#getting-started

    Read Article →

    Facebook buttons with CSS


    Facebook  has a nice collection of buttons those are simple but really nice. Facebook ui like buttons are really awesome.
    So how can you include Facebook like CSS buttons into your website or blog?
    it is so simple . you have to insert CSS style code to your header section and you can make any button or element with adding a  class to that.

    Here is a live demo.

    Buttons







    Buttons Group


    Buttons Toolbar



    Here is the HTML Code i have used for this demo

    <h1>Buttons</h1>
    <button class='uibutton'>button</button>
    <button class='uibutton large'>button large</button>
    <br/>
    <br/>
    <button class='uibutton confirm'>confirm button</button>
    <button class='uibutton confirm large'>confirm button large</button>
    <br/>
    <br/>
    <button class='uibutton special'>special button</button>
    <button class='uibutton special large'>special button large</button>
    <br/>
    <br/>
    <h1>Buttons Group</h1>
    <div class='uibutton-group'>
    <button class='uibutton'>button</button>
    <button class='uibutton confirm'>button</button>
    <button class='uibutton special'>button</button>
    </div>
    <br/>
    <br/>
    <h1>Buttons Toolbar</h1>
    <div class='uibutton-toolbar'>
    <button class='uibutton'>button</button>
    <button class='uibutton'>button</button>
    </div>


    And here goes the CSS style

    <style type='text/css'>
    .uibutton {
    position: relative;
    z-index: 1;
    overflow: visible;
    display: inline-block;
    padding: 0.3em 0.6em 0.375em;
    border: 1px solid #999;
    border-bottom-color: #888;
    margin: 0;
    text-decoration: none;
    text-align: center;
    font: bold 11px/normal 'lucida grande', tahoma, verdana, arial, sans-serif;
    white-space: nowrap;
    cursor: pointer;
    /* outline: none; */
    color: #333;
    background-color: #eee;
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f6f6), to(#e4e4e3));
    background-image: -moz-linear-gradient(#f5f6f6, #e4e4e3);
    background-image: -o-linear-gradient(#f5f6f6, #e4e4e3);
    background-image: linear-gradient(#f5f6f6, #e4e4e3);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f5f6f6', EndColorStr='#e4e4e3'); /* for IE 6 - 9 */
    -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #fff;
    -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #fff;
    /* IE hacks */
    zoom: 1;
    *display: inline;
    }

    .uiButton{cursor:pointer;display:inline-block;font-size:11px;font-weight:bold;line-height:13px;padding:2px 6px;text-align:center;text-decoration:none;vertical-align:top;white-space:nowrap}
    .uiButton, .uiButtonSuppressed:active, .uiButtonSuppressed:focus, .uiButtonSuppressed:hover{background-image:url(//m-static.ak.fbcdn.net/rsrc.php/v2/ys/x/t0WxoMd7EqC.png);background-repeat:no-repeat;background-size:auto;background-position:-352px -401px;background-color:#eee;border:1px solid #999;border-bottom-color:#888;-webkit-box-shadow:0 1px 0 rgba(0, 0, 0, .1)}
    .uiButton + .uiButton{margin-left:4px}
    .uiButton:hover{text-decoration:none}
    .uiButton:active, .uiButtonDepressed{background:#ddd;border-bottom-color:#999;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, .2)}
    .uiButton .img{margin-top:2px;vertical-align:top}

    .uibutton:hover,
    .uibutton:focus,
    .uibutton:active {
    border-color: #777 #777 #666;
    }

    .uibutton a:hover{
    text-decoration:none;
    }
    .uibutton:active {
    border-color: #aaa;
    background: #ddd;
    filter: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
    }

    /* overrides extra padding on button elements in Firefox */
    .uibutton::-moz-focus-inner {
    padding: 0;
    border: 0;
    }

    /* ............................................................................................................. Icons */

    .uibutton.icon:before {
    content: "";
    position: relative;
    top: 1px;
    float:left;
    width: 10px;
    height: 12px;
    margin: 0 0.5em 0 0;
    background: url(fb-icons.png) 99px 99px no-repeat;
    }

    .uibutton.edit:before { background-position: 0 0; }
    .uibutton.add:before { background-position: -10px 0; }
    .uibutton.secure:before { background-position: -20px 0; }
    .uibutton.prev:before { background-position: -30px 0; }
    .uibutton.next:before { float:right; margin: 0 -0.25em 0 0.5em; background-position: -40px 0; }

    /* ------------------------------------------------------------------------------------------------------------- BUTTON EXTENSIONS */

    /* ............................................................................................................. Large */

    .uibutton.large {
    font-size:13px;
    }

    /* ............................................................................................................. Submit, etc */

    .uibutton.confirm {
    border-color: #29447E #29447E #1A356E;
    color: #fff;
    background-color: #5B74A8;
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#637bad), to(#5872a7));
    background-image: -moz-linear-gradient(#637bad, #5872a7);
    background-image: -o-linear-gradient(#637bad, #5872a7);
    background-image: linear-gradient(#637bad, #5872a7);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#637bad', EndColorStr='#5872a7'); /* for IE 6 - 9 */
    -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #8a9cc2;
    -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #8a9cc2;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #8a9cc2;
    }

    .uibutton.confirm:active {
    border-color: #29447E;
    background: #4F6AA3;
    filter: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
    }

    /* ............................................................................................................. Special */

    .uibutton.special {
    border-color: #3b6e22 #3b6e22 #2c5115;
    color: #fff;
    background-color: #69A74E;
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#75ae5c), to(#67a54b));
    background-image: -moz-linear-gradient(#75ae5c, #67a54b);
    background-image: -o-linear-gradient(#75ae5c, #67a54b);
    background-image: linear-gradient(#75ae5c, #67a54b);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#75ae5c', EndColorStr='#67a54b'); /* for IE 6 - 9 */
    -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #98c286;
    -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #98c286;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #98c286;
    }

    .uibutton.special:active {
    border-color: #3B6E22;
    background: #609946;
    filter: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
    }


    /* ------------------------------------------------------------------------------------------------------------- BUTTON GROUPS */

    .uibutton-group {
    display: inline-block;
    list-style: none;
    padding: 0;
    margin: 0;
    /* IE hacks */
    zoom: 1;
    *display: inline;
    }

    .uibutton + .uibutton,
    .uibutton + .uibutton-group,
    .uibutton-group + .uibutton,
    .uibutton-group + .uibutton-group {
    margin-left: 3px;
    }

    .uibutton-group li {
    float: left;
    padding: 0;
    margin: 0;
    }

    .uibutton-group .uibutton {
    float: left;
    margin-left: -1px;
    }

    .uibutton-group .uibutton:hover,
    .uibutton-group .uibutton:focus,
    .uibutton-group .uibutton:active {
    z-index:2;
    }

    .uibutton-group > .uibutton:first-child,
    .uibutton-group li:first-child .uibutton {
    margin-left: 0;
    }

    /* ------------------------------------------------------------------------------------------------------------- BUTTON CONTAINER */
    /* For mixing buttons and button groups, e.g., in a navigation bar */

    .uibutton-toolbar {
    padding: 6px;
    border-top: 1px solid #ccc;
    background: #f2f2f2;
    }

    .uibutton-toolbar .uibutton,
    .uibutton-toolbar .uibutton-group {
    vertical-align: bottom;
    }
    </style>


    And here is a demo you can play with :

    http://jsfiddle.net/Aslamise/KEbFU/

    Hope this helps.
    feel free to discuss about this :)

    Read Article →

    How to add Google translate to website or blog



    Google translator is best service ever to translate between languages with ease.
    Nowadays, many websites and blogs are make use of this feature. it will help user to read website contents in their language. Google does give an option to show a banner for users for those who are not using our website's default language as their system language.
    thus Google translator makes it easy for users to read and understand everything in their language.

    To add Google translator service to your website or blog, follow steps below. its so simple as anything.

    Go to
    http://translate.google.com/manager/website/add


    You will see a text field titled with Website URL. with a subtitle of What is the URL of your website.

    Enter your website URL here. if you are having a sub domain and not a domain, like a blogspot.com domain,
    type the address here.

    Next, is Website Language
    It will ask for what is the original language of your website.
    so if you have a website with its contents in English language, select default language as English.
    And if you have a website with contents in other language, just select that language.

    Click Next.





    Now you will be in plugin settings Tab.

    you will see a field titled as translation languages.

    select All languages, if you want to enable translation to all languages.
    or if you want to enable translation to only some languages, you can select "Specific languages" option  and select languages.

    Select display mode.
    Three options are there

    1. Vertical
    2. Horizontal
    3. Drop down only


    When you select this option , sample of the widget displays on right side.

    Under advanced title option

    "Automatically display translation banner to users speaking languages other than the language of your page. "
    Check this option if you want to. i recommend to check this.

    If you have contents in multiple languages, then check next option "Your page contains contents in multiple languages"

    If you want to, you can use Google analytic to track translation usage.

    Click "next" button. you will be agreeing to Google's terms and conditions.





    You are almost done, but you have to add the code to your blog or website to get it to work.

    Add the first code meta code to section

    It will look like this.

    <meta content='e3ca32bb0a4tgtrr09d-5b78317696fryr863-g5bc9rye-15' name='google-translate-customization'/>

    Now add the next code(Widget code), wherever you want to display the translation option

    It will look same as this.



    <div id="google_translate_element"></div><script type="text/javascript">
    function googleTranslateElementInit() {
    new google.translate.TranslateElement({pageLanguage: 'en', 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>



    If you are blogger, using blogspot.com sub domain, you can use add add widget option in Layout Section

    After completing the above steps, test run your website and check whether it works or not.
    iif you are having problems, feel free to ask in comments.


    Read Article →

    How to remove <br> tag from two <br> tags using jQuery


    Here is a nice solution for those who want to remove one tag from where two tags comes together.


    <p>A paragraph</p>
    <br>
    <br>
    <p>Another Paragraph</p>
    <br>
    <br>
    <p>Another Paragraph</p>


    So, if you have used blogger to post something, you may have noticed that when we click enter, it automatically interpreted as a tag.
    :I have felt this problem in my blog too:

    So the basic selector syntax using jQuery is

    jQuery('document').ready(function() {
    $( ' br + br').remove();
    }

    If you want ot remove one tag only within <pre> tags, then it comes like this

    jQuery('document').ready(function() {
    $( 'pre br + br').remove();
    }

    After loading the page, above example will converted to


    <p>A paragraph</p>
    <br>
    <p>Another Paragraph</p>
    <br>
    <p>Another Paragraph</p>


    Here is the final solution for those who want to remove All doubled tags.


    jQuery('document').ready(function() {
     $( 'br + br').remove();
     }


    And here is the solution for those who want to remove All doubled tags only within <pre> tags.


    jQuery('document').ready(function() {
    $( 'br + br').remove();
    }


    Below is other ways with jQuery. These will work. but above solution is recommended!

    $('br').next('br').remove();
    $('br').prev('br').remove();


      Read Article →

      How to Enable/Disable default lightbox for images in blogger

      Here is how you can enable or disable blogger's default lightbox plugin on your blog.
      If you need more advanced controls, you will have to disable it and search for any other Lightbox plugin like jQuery Pretty photo plugin.

      So, if you want to enable light box for blogger images, then
      Go to blogger dashboard by signing in to your blogger.com account.

      Select your blog to enable or disable Default light box.
      Click on options, Select Settings
      It will open up settings tab for selected blog.

      In settings -> select Posts and comments option


      in sub menu -> you can see An option > showcase images with light box.



      To enable light box, select Yes from drop-down menu,


      if you are using any other plugin to showcase images, then
      Select NO from drop down.


      Note: If you are using any other light box plugin, then it is better to disable default light box in blogger else it will cause problems with your template.

      Hope this helps you!:)

      Read Article →

      Altrernative for marquee tag - with webkit animation

      You can see a live demo in this page for alternative of marquee tag in webkit browsers with speed control.
      Aslamise.blogspot.com - Aslam's little place on the clouds! - By Muhammed Aslam C


      Here is the basic markup for the demo you are seeing.
      <div id="outer">
       <div id="inner">Aslamise.blogspot.com <b>Aslam's little place on the clouds!</b><b>By Muhammed Aslam C</b></div>
      </div

      And here goes the CSS to do the animation in web-kit browsers



      <style type="text/css">
       @-webkit-keyframes bar { 0% { left: 100% } 100% { left: -200% }}#outer {
       height: 24px;
       overflow: hidden;
       background: #fff;
       background: -webkit-gradient(linear, left top, left bottom, from(#fbfbfb), to(#dfdfdf));
       position: fixed;
       top: 0px;
       right: 0px;
       width: 100%;
       z-index: 9999;
      }
      #inner {
       height: 24px;
       width: 200%;
       position: relative;
       font: 20px Helvetica;
       line-height: 26px;
       text-transform: uppercase;
       text-shadow: #fdfdfd 0 1px 0;
       -webkit-animation: bar 25s infinite linear;}
      </style>


      Here i have marked two style blocks in yellow background.
      This is where we tell to browser to do a marquee like animation.


       @-webkit-keyframes bar {
       0% { left: 100% }
       100% { left: -200% }
      }

      Above we declared is animation : named as bar, which will move the element from left 100% to left 200% , and it will do the trick.

      Next step is to add animation  to any element we want to.
      . inner{
       -webkit-animation: bar 25s infinite linear;
      }

      element with a class of "inner" will call the animation, for an infinite loop in the speed of 12 seconds. you can change the "25s" to any. Higher the value, animation will be slow.


      Read Article →

      Nice and beautiful paging buttons with CSS

      Here is how you can create nice and beautiful paging buttons with css. Below is a live demo.






      Here is the souce code and explanations for this stylish paging buttons.

      Basic markup code for our paging button goes like this.



      <ul id="pagin">
      <li><a class="current" href="#">1</a></li>
      <li><a href="#">2</a></li>
      <li><a href="#">3</a></li>
      <li><a href="#">4</a></li>
      <li><a href="#">next</a></li>
      </ul>




      And here is the CSS code that makes our paging buttons more beautiful.



      <style type='text/css'>
      #pagin {
      margin: 65px auto;
      padding: 0;
      list-style: none;
      width: 180px;
      }
      #pagin li {
      float: left;
      margin-right: 10px;
      }
      #pagin li a {
      display: block;
      text-decoration: none;
      color: #717171;
      font: bold 11px Arial, sans-serif;
      text-shadow: 0px 1px white;
      padding: 5px 8px;
      -webkit-border-radius: 3px;
      -moz-border-radius: 3px;
      border-radius: 3px;
      -webkit-box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.35);
      -moz-box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.35);
      box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.35);
      background: #f9f9f9;
      background: -webkit-linear-gradient(top, #f9f9f9 0%, #e8e8e8 100%);
      background: -moz-linear-gradient(top, #f9f9f9 0%, #e8e8e8 100%);
      background: -o-linear-gradient(top, #f9f9f9 0%, #e8e8e8 100%);
      background: -ms-linear-gradient(top, #f9f9f9 0%, #e8e8e8 100%);
      background: linear-gradient(top, #f9f9f9 0%, #e8e8e8 100%);
      filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f9f9f9', endColorstr='#e8e8e8',GradientType=0 );
      }
      #pagin li a.current {
      color: white;
      text-shadow: 0px 1px #3f789f;
      -webkit-box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.8);
      -moz-box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.8);
      box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.8);
      background: #7cb9e5;
      background: -webkit-linear-gradient(top, #7cb9e5 0%, #57a1d8 100%);
      background: -moz-linear-gradient(top, #7cb9e5 0%, #57a1d8 100%);
      background: -o-linear-gradient(top, #7cb9e5 0%, #57a1d8 100%);
      background: -ms-linear-gradient(top, #7cb9e5 0%, #57a1d8 100%);
      background: linear-gradient(top, #7cb9e5 0%, #57a1d8 100%);
      filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7cb9e5', endColorstr='#57a1d8',GradientType=0 );
      }
      #pagin li a:hover {
      -webkit-box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.55);
      -moz-box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.55);
      box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.55);
      background: #fff;
      background: -webkit-linear-gradient(top, #fff 0%, #e8e8e8 100%);
      background: -moz-linear-gradient(top, #fff 0%, #e8e8e8 100%);
      background: -o-linear-gradient(top, #fff 0%, #e8e8e8 100%);
      background: -ms-linear-gradient(top, #fff 0%, #e8e8e8 100%);
      background: linear-gradient(top, #fff 0%, #e8e8e8 100%);
      filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fff', endColorstr='#e8e8e8',GradientType=0 );
      }
      #pagin li a:active,#pagin li a.current:active {
      -webkit-box-shadow: inset 0px 1px 3px 0px rgba(0,0,0,0.5), 0px 1px 1px 0px rgba(255,255,255,1) !important;
      -moz-box-shadow: inset 0px 1px 3px 0px rgba(0,0,0,0.5), 0px 1px 1px 0px rgba(255,255,255,1) !important;
      box-shadow: inset 0px 1px 3px 0px rgba(0,0,0,0.5), 0px 1px 1px 0px rgba(255,255,255,1) !important;
      }
      #pagin li a.current:hover {
      -webkit-box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.9);
      -moz-box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.9);
      box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.9);
      background: #99cefc;
      background: -webkit-linear-gradient(top, #99cefc 0%, #57a1d8 100%);
      background: -moz-linear-gradient(top, #99cefc 0%, #57a1d8 100%);
      background: -o-linear-gradient(top, #99cefc 0%, #57a1d8 100%);
      background: -ms-linear-gradient(top, #99cefc 0%, #57a1d8 100%);
      background: linear-gradient(top, #99cefc 0%, #57a1d8 100%);
      filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#99cefc', endColorstr='#57a1d8',GradientType=0 );
      }
      </style>







      Read Article →

      How to add a class to any element using jQuery or JavaScript


      If you are a good web designer, you will always think of how to automate things without wasting our valuable time.
      This is one of the question every web designer/web developer thinks of. how to automate things!

      Here we will discuss about how to add classes to elements automatically on page load.
      lets have a look at what are the benefits of assigning classes automatically.

      • Spend no time to add all classes by hand
      • Accuracy
      • Faster Page loads

      jQuery's Basic syntax to add class is 
      $("elementID").addClass("ClassName")
      To use jQuery,you will have to add jQuery library between your<head></head> tags.
      If you have not yet included jQuery in your webpages, its the time to do that. dont be afraid that the size of jQuery Script will affect your pageloading time,because it is less than 100 kb if minimized.(Smaller than a normal image i would say). 
      To Call jQuery, find </head> tag in your code.then Copy and paste the below code just before that </head> tag.
      <script src='//code.jquery.com/jquery-1.8.0.min.js' type='text/javascript'></script>

      How to add a class to all "img" tags at a time using jQuery or JavaScript

      Imagine that you have  many images in your website or blog.
      and you want to automate the process of adding a class called "my-sample-class-for-all-img-tags" to all <img>  tags inside the document.

      Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to all "img" tag in document:

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $("img").addClass("my-sample-class-for-all-img-tags");
      });
      </script>

      JavaScript Code for adding a class to all "img" tag in document :

      <script type='text/JavaScript'>
      var images = document.getElementsByTagName("img");
      var i;
      for(i = 0; i < images.length; i++) {
          images[i].className += " my-sample-class-for-all-img-tags";
      }
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-all-img-tags" will be added to all img tags inside the webpage.

      How to add a class to all pre tags at a time using jQuery or JavaScript

      Imagine that you have  many pre tags in your website or blog.
      and you want to automate the process of adding a class called "my-sample-class-for-all-pre-tags" to all <pre>  tags inside the document.

      Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to all "pre" tag in document:

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $("pre").addClass("my-sample-class-for-all-pre-tags");
      });
      </script>

      JavaScript Code for adding a class to all "pre" tag in document :

      <script type='text/JavaScript'>
      var pres = document.getElementsByTagName("pre");
      var i;
      for(i = 0; i < pres.length; i++) {
          pres[i].className += " my-sample-class-for-all-pre-tags";
      }
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-all-pre-tags" will be added to all pre tags inside the webpage.


      How to add a class to all code tags at a time using jQuery or JavaScript

      Imagine that you have  many <code> tags in your website or blog.
      and you want to automate the process of adding a class called "my-sample-class-for-all-code-tags" to all <code>  tags inside the document.

      Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to all "code" tag in document:

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $("code").addClass("my-sample-class-for-all-code-tags");
      });
      </script>

      JavaScript Code for adding a class to all "img" tag in document :

      <script type='text/JavaScript'>
      var codes = document.getElementsByTagName("code");
      var i;
      for(i = 0; i < codes.length; i++) {
          codes[i].className += " my-sample-class-for-all-code-tags";
      }
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-all-code-tags" will be added to all <code> tags inside the webpage.


      How to add a class to all div tags at a time using jQuery or JavaScript

      If you want to automate the process of adding a class called "my-sample-class-for-all-div-tags" to all <div>  tags inside the document.

      Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to all "img" tag in document:

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $("div").addClass("my-sample-class-for-all-div-tags");
      });
      </script>

      JavaScript Code for adding a class to all "div" tag in document :

      <script type='text/JavaScript'>
      var divs = document.getElementsByTagName("div");
      var i;
      for(i = 0; i < divs.length; i++) {
          divs[i].className += " my-sample-class-for-all-div-tags";
      }
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-all-div-tags" will be added to all div tags inside the webpage.

      How to add a class to all button tags at a time using jQuery or JavaScript

      Imagine that you have  <button> tags in your website or blog.
      and you want to automate the process of adding a class called "my-sample-class-for-all-button-tags" to all <button>  tags inside the document.

      Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to all "img" tag in document:

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $("button").addClass("my-sample-class-for-all-button-tags");
      });
      </script>

      JavaScript Code for adding a class to all "img" tag in document :

      <script type='text/JavaScript'>
      var buttons = document.getElementsByTagName("button");
      var i;
      for(i = 0; i < buttons.length; i++) {
          buttons[i].className += " my-sample-class-for-all-button-tags";
      }
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-all-button-tags" will be added to all <button> tags inside the webpage.

      How to add a class to all input tags at a time using jQuery or JavaScript

      Imagine that you have  <input> tags in your website or blog.
      and you want to automate the process of adding a class called "my-sample-class-for-all-input-tags" to all <input>  tags inside the document.

      Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to all "input" tag in document:

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $("input").addClass("my-sample-class-for-all-input-tags");
      });
      </script>

      JavaScript Code for adding a class to all "input" tag in document :

      <script type='text/JavaScript'>
      var inputs = document.getElementsByTagName("input");
      var i;
      for(i = 0; i < inputs.length; i++) {
          inputs[i].className += " my-sample-class-for-all-input-tags";
      }
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-all-input-tags" will be added to all <input> tags inside the webpage.

      How to add a class to all textarea tags at a time using jQuery or JavaScript

      Imagine that you have  <textarea> tags in your website or blog.
      and you want to automate the process of adding a class called "my-sample-class-for-all-textarea-tags" to all <textarea>  tags inside the document.

      Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to all "textarea" tag in document:

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $("textarea").addClass("my-sample-class-for-all-textarea-tags");
      });
      </script>

      JavaScript Code for adding a class to all "textarea" tag in document :

      <script type='text/JavaScript'>
      var textareas = document.getElementsByTagName("textarea");
      var i;
      for(i = 0; i < textareas.length; i++) {
          textareas[i].className += " my-sample-class-for-all-textarea-tags";
      }
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-all-textarea-tags" will be added to all <textarea> tags inside the webpage.

      How to add a class to all span tags at a time using jQuery or JavaScript

      Imagine that you have  <span> tags used in your website or blog.
      and you want to automate the process of adding a class called "my-sample-class-for-all-span-tags" to all <span>  tags inside the document.

      Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to all "span" tag in document:

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $("span").addClass("my-sample-class-for-all-span-tags");
      });
      </script>

      JavaScript Code for adding a class to all "span" tag in document :

      <script type='text/JavaScript'>
      var spans = document.getElementsByTagName("span");
      var i;
      for(i = 0; i < spans.length; i++) {
          spans[i].className += " my-sample-class-for-all-span-tags";
      }
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-all-span-tags" will be added to all Span tags inside the webpage.

      How to add a class to html tag on page load using jQuery or JavaScript

      If you want to add a class to your <html> tag on pageload,Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to "html" tag

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $("html").addClass("my-sample-class-for-html-tag");
      });
      </script>

      JavaScript Code for adding a class to "html" tag

      <script type='text/JavaScript'>
      var htmltag = document.getElementsByTagName("html");
      htmltag[0].className += " my-sample-class-for-html-tag";
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-html-tag" will be added to <html> tag.

      How to add a class to body tag on page load using jQuery or JavaScript

      If you want to add a class to your <body> tag on pageload,Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to "body" tag

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $("body").addClass("my-sample-class-for-body-tag");
      });
      </script>

      JavaScript Code for adding a class to "body" tag 

      <script type='text/JavaScript'>
      var bodytag = document.getElementsByTagName("body");
      bodytag[0].className += " my-sample-class-for-body-tag";
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-body-tag" will be added to <body> tag.

      How to add a class to an element with specific class on page load using jQuery or JavaScript

      If you want to add a class to an element with specific class on pageload,Add below code just before closing body tag (</body>).

      jQuery Script for adding a class to an element with specifc class.

      <script type='text/JavaScript'>
      jQuery('document').ready(function(){
      $(".existing-class-name").addClass("my-sample-class-for-element-with-a-class-of-existing-class-name");
      });
      </script>

      JavaScript Code for adding a class to an element with specifc class.

      <script type='text/JavaScript'>
      var classes = document.getElementsByClassName("existing-class-name-to-find");
      var i;
      for(i = 0; i < classes.length; i++) {
          classes[i].className += " my-sample-class-for-all-elements-with-class-of-existing-class-name-to-find";
      }
      </script>

      Save,and you are done.
      Next time when you refresh the output page, a class named "my-sample-class-for-all-elements-with-class-of-existing-class-name-to-find" will be added to all elements which was having a "existing-class-name-to-find" class.


      Important Notes:

      • Dont forget to include jQuery library before you experiment with jquery sample codes above,a small description on how to add jQuery to your page is explained in the beginning of this article.
      • Dont forget to replace class names and tags with your own classnames which you used in your blog or website.

      Press ctrl+D to bookmark and Please leave your comments and thoughts below :)


      Read Article →