Wednesday, October 9, 2013

Jquery textbox accept only alpha characters

HTML


Jquery

$('#alphaonly').bind('keypress', function (event) { var regex = new RegExp("^[a-zA-Z]+$"); var key = String.fromCharCode(!event.charCode ? event.which : event.charCode); if (!regex.test(key)) { event.preventDefault(); return false; } });

Thursday, October 3, 2013

Browser specific hack


Chrome Hack only

@media screen and (-webkit-min-device-pixel-ratio:0) { .ar #form-wrapper { width: 330px; } }

Firefox Hack only

@-moz-document url-prefix() { .submit_btn { padding-bottom: 5px; } }

IE8 Hack

@media screen { .item { background: #000; } }

IE9 Hack

:root #nav li.last-page-item a { padding-right:8px\9; }

coloe:red\9; hack works on IE9

Wednesday, September 25, 2013

CSS3 Background-size

CSS3


html{ background-image: url(http://coastsidefishingclub.com/site/wp-content/themes/csf/images/bg-img.jpg); background-repeat:no-repeat; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; }

Wednesday, September 4, 2013

keypress uppercase jquery


Jquery

$("#ctag").bind('keyup', function (e) { if (e.which >= 97 && e.which <= 122) { var newKey = e.which - 32; e.keyCode = newKey; e.charCode = newKey; } $("#ctag").val(($("#ctag").val()).toUpperCase()); });

Monday, August 26, 2013

jQuery add class based on page URL


Jquery

$(function(){ function stripTrailingSlash(str) { if(str.substr(-1) == '/') { return str.substr(0, str.length - 1); } return str; } var url = window.location.pathname; var activePage = stripTrailingSlash(url); $('#left-nav ul li a').each(function(){ var currentPage = stripTrailingSlash($(this).attr('href')); if (activePage == currentPage) { $(this).addClass('active'); } }); });

Wednesday, August 21, 2013

Target only Safari and Chrome with CSS

CSS

@media screen and (-webkit-min-device-pixel-ratio:0) {

#title {
color: red !important;
}
}

Friday, August 16, 2013

set margin for span tag

CSS

display:inline-block

span is an inline element, not a block element, and they don't respect margin. You can use padding or make the span display:inline-block; and then use margins.

Javascript find highest and lowest from the given inputs

function highAndLow(numbers){ // numbers = "4 5 29 54 4 0 -214 542 -64 1 -3 6 -6"   let numbersInArr = numbers.split(' ...