How to make input numeric only in jQuery

To make input numeric only in jQuery you can use the following snippet.

Sample jQuery

$('input.numbersOnlyinput').bind('keypress', function(input) {   
    return (input.which === 0 || input.which === 8 || (input.shiftKey === false && (input.which < 58 && input.which > 47))) ? true : false;   
}

Please rate this snippet

How to create zebra table effect with jQuery and CSS

To create zebra table effect with jQuery and CSS you can use the following snippet.

jQuery

$("tr:odd").addClass("oddRowsEffect");

in the css you need something like

tr.oddRowsEffect{
/* background: choose a color; *
/* color: choose a color; *
}

Please rate this snippet

How to detect orientation and change the css file in Javascript

To detect orientation and change the css file in Javascript you can use the following snippet.

Sample Javascript

function orient()  
{  
 switch(window.orientation){    
	case 0: document.getElementById("orient_css").href = "css/iphone_portrait.css";  
	break;  
	case 90: document.getElementById("orient_css").href = "css/iphone_landscape.css";  
	break;  
	case -90: document.getElementById("orient_css").href = "css/iphone_landscape.css";  
	break;  
}
window.onload = orient();

Please rate this snippet

How to scroll to the top of the page in jQuery

To scroll to the top of the page in jQuery you can use the following snippet. This will scroll smmooth to the top of the page, for a instant scroll look at the Javascript Version.

Sample jQuery

$("a[href='#gotoTop']").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");
  return false;
});

Please rate this snippet