William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

Some JS examples

Some JS examples

Here are some of my JS/jQuery examples for quick retrieving:


//1. set _debug flag to auto switch log future in different envs:
_debug: /(williamjiang|localhost)/i.test(document.location.hostname),

//2.
this
 .filter(":has(>ul):not(:has(>a))")
 .find(">span")
 .unbind("click.tree")
 .bind("click.tree", function(event) {
   if ( this == event.target )
    toggler.apply($(this).next());
  }).add( $("a", this) ).hoverClass();

branches.each(function(i, e) {
  data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0;
});

$('li.third-item').nextAll().andSelf()
  .css('background-color', 'red');
  
//3.on(), off() 
var switchListHandler=function(e){
    if (typeof (e) == "undefined")
        e = window.event;
    if (typeof (e) == "undefined")
        return false;
    var srcEle = e.srcElement;
    if (!srcEle) srcEle = e.target;
    if(srcEle.tagName.toUpperCase()=='A') {...}    	
};

$(document).on('click', 'body', CountList.switchListHandler);

$(document).off('click', 'body', CountList.switchListHandler);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: