Showing posts with label jQuery. Show all posts
Showing posts with label jQuery. Show all posts

Friday, September 2, 2011

Load jQuery Asyc

This is a good javascript plugin that loads jQuery async and runs document.ready after jQuery is loaded and DOM initilized.

http://www.yterium.net/jQl-an-asynchronous-jQuery-Loader

Thursday, August 18, 2011

jQuery Detect Browser


// Target Firefox 2 and above   
if  ($.browser.mozilla && $.browser.version >= "1.8" ) {
// do something   
}
// Target Safari   
if  ($.browser.safari) {
// do something   
}
// Target Chrome   
if  ($.browser.chrome) {
// do something   
}
// Target Camino   
if  ($.browser.camino) {
// do something   
}
// Target Opera   
if  ($.browser.opera) {
// do something   
}
// Target IE6 and below   
if  ($.browser.msie && $.browser.version <= 6) {
// do something   
}
// Target anything above IE6   
if  ($.browser.msie && $.browser.version > 6) {
// do something   
}

jQuery Check element exists

if ($('#id' ).length) {
// do something
}


Wednesday, August 10, 2011

toTitleCase jQuery Plugin


(function  ($) {
$.fn.toTitleCase = function  () {
$(this ).each(function  () {
var  headline = $(this ).text();
$(this'\uc1\u8216?\uc1\u8217?"\uc1\u8220?.@:\\/\\{\\(\\[<>_]+-? *)/g, function  (match, pl, index, title) {
if  (index > 0 && title.charAt(index - 2) !== ":"  && match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\\.?|via)[ \\-]/i) > -1)
return  match.toLowerCase();
if  (title.substring(index - 1, index +'"_{(\\[]/) > -1)
return  match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);
if  (match.substr(1).search(/[A-Z]+|&|[\\w]+[._][\\w]+/) > -1 || title.substring(index - 1, index + 1).search(/[\\])}]/) > -1)
return  match;
return  match.charAt(0).toUpperCase() + match.substr(1);
}));
});
};
})(jQuery);
Source: http://plugins.jquery.com/project/titlecase

Monday, August 8, 2011

Simple jQuery Plugin to Clear Dropdownlist options


$.fn.clearOption = function  () {
var  currentId = $(this ).attr( );
document.getElementById(currentId).options.length = 0;
};
 
paste this code in a external js file. clear the option element
of a Dropdownlist using the folowing jQuery syntax.

$("#Dropdownlist1" ).clearOption();