Skip to content

Instantly share code, notes, and snippets.

@ledsun
Created June 11, 2012 06:46
Show Gist options
  • Save ledsun/2908775 to your computer and use it in GitHub Desktop.
Save ledsun/2908775 to your computer and use it in GitHub Desktop.
javascriptイディオム

javascriptでよくある操作

disable

$('hoge').attr("disabled", "disabled");
$('hoge').removeAttr("disabled");

Dateインスタンスを複製

var one = new Date();
var another = new Date(one.getTime());

jQueryでよくある操作

event.targetでイベントが発生したjQueryオブジェクトを取得

 $('hoge')
     .change(function (event) {
         alert(event.target).val());
     });

plugin

; (function ($) {
    $.fn.example = function (hoge) {
        return this.each(function () { alert('hoge'); });
    });
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment