레이블이 jquery인 게시물을 표시합니다. 모든 게시물 표시
레이블이 jquery인 게시물을 표시합니다. 모든 게시물 표시

2012년 10월 22일 월요일

JQuery Rowspan

(function($){
$.fn.rowspan = function(colIdx) {
return this.each(function(){
var that;
   $('tbody tr', this).each(function(row) {
    $('td:eq('+colIdx+')', this).each(function(col) {
       if ($(this).html() == $(that).html()) {
           rowspan = $(that).attr("rowSpan");
           if (rowspan == undefined) {
            $(that).attr("rowSpan",1);
            rowspan = $(that).attr("rowSpan");
           }
           rowspan = Number(rowspan)+1;
           $(that).attr("rowSpan",rowspan); // do your action for the colspan cell here
           $(this).hide(); // .remove(); // do your action for the old cell here
       } else {
           that = this;
          }
          that = (that == null) ? this : that; // set the that if not already set
      });
    });
  });
};
})(jQuery);

2011년 12월 19일 월요일

JQuery HashMap

정말 유용..

프로그래밍 하신분이라면 설명이 따로 필요 없을듯...

Map.prototype = {
    put : function(key, value){
        this.map[key] = value;
    },
    get : function(key){
        return this.map[key];
    },
    containsKey : function(key){  
     return key in this.map;
    },
    containsValue : function(value){  
     for(var prop in this.map){
      if(this.map[prop] == value) return true;
     }
     return false;
    },
    isEmpty : function(key){  
     return (this.size() == 0);
    },
    clear : function(){
     for(var prop in this.map){
      delete this.map[prop];
     }
    },
    remove : function(key){  
     delete this.map[key];
    },
    keys : function(){
        var keys = new Array();
        for(var prop in this.map){
            keys.push(prop);
        }
        return keys;
    },
    values : function(){
     var values = new Array();
        for(var prop in this.map){
         values.push(this.map[prop]);
        }
        return values;
    },
    size : function(){
      var count = 0;
      for (var prop in this.map) {
        count++;
      }
      return count;
    }
};