Home > jQuery

jQuery Archive

デバッグ用 jQuery プラグイン

たくさん console.log 書くのが面倒なのでこんな風にしてます。

(function($){$.extend($.prototype,{
op: function(s){
    s = $.extend({o: console.log, n: toString}, s);
    $(this).each(function(){
        s.o('{width: '+$(this).width()+', height: '+$(this).height()+', scrollLeft: '+$(window).scrollLeft()+', scrollTop: '+$(this).scrollTop()+'} as '+s.n.call($(this)[0]));
    });
}})})(jQuery);

プラグインと言うほどの物ではありませんね。
$(selector).op(); で console.log に {width: nnn, height: nnn, scrollLeft: nnn, scrollTop: nnn} as [object name] が表示されるだけ。
jquery ui の resize() メソッドにつなげて確認、みたいな。
$(selector).op({o:$(’#log’).html}); とかでもいけるけど追記するような処理加えないと複数要素が駄目。

ホーム > jQuery

Search
Feeds
Meta

Return to page top