jQuery トランジションありのスライドショー

2010年06月24日(木)

こんなのあればいいなーと思ってました。
トランジションありのスライドショーです。

http://workshop.rs/projects/coin-slider/

jQuery li複数のシミュレーション用

2010年06月21日(月)

良くレイアウトをCSSで組む際に
リストが複数ある状態をシミュレーションするためにわざわざli要素をコピーとかするんですが
このスクリプトを制作のときに入れておけば楽でした。
li要素を変更したときにも役立ちます。

list='<li>'+$("#sample_list li:first").html()+'</li>';
for(i=0;i<10;i++){
    $("#sample_list ul").append(list);
}

テスト用なので、稼働時には外しますが。

jQuery キューはqueue()

2010年06月17日(木)

要素のqueueはqueue()で配列として取得できるそうです。

 $("#animatede_id").queue().length;

これつかっとけばよかったです。

Javascript クラス

2010年05月29日(土)

JavaScriptでオブジェクト指向プログラミング
http://www.atmarkit.co.jp/fdotnet/ajaxjs/ajaxjs04/ajaxjs04_01.html

なんだかjqueryのプラグインを作っていて思いましたが
これもクラスもどきを作っているのですかね。
あまり明確なクラスの定義はないようですが、なんとなく。

jQuery プラグイン修正版

2010年05月03日(月)

前回のエントリーを修正しました。
というより前のがひどすぎました。

jQuery.fn.biyoon = function(scale,duration,easing){

		//var target = this;
		return this.each(function(){
			ini_width=jQuery(this).attr("width");
			ini_height=jQuery(this).attr("height");
			jQuery(this).data({"ini_width":ini_width,"ini_height":ini_height});
			jQuery(this).bind("mouseover",biyon).bind("mouseout",rbiyon);
		//return target;
		});

		//拡大
		function biyon(e){
			selector=e.target;
			after_width=selector.width*scale+"px";
			after_height=selector.height*scale+"px";
			$(selector).stop().animate({width:after_width,height:after_height},duration,easing);
		}

		//戻す
		function rbiyon(e){
			selector=$(e.target);
			selector.stop().animate({width:selector.data("ini_width"),height:selector.data("ini_height")},duration,easing);
		}

	};

jQuery はじめてのjQueryプラグイン(駄作)

2010年05月01日(土)

初めてのjQueryぷらぐいんです。しょぼー!
画像がびよーんってなります。
jquery.easing.jsが必要です。

2010.5.1 追記:
この内容、あまりにひどすぎたので修正版を次回エントリーに。
http://blog.macaroniworks.net/2010/05/jquery-プラグイン修正版/

jQuery.fn.biyoon = function(scale,duration,easing){

		var target = this;
		target.bind("mouseover",biyon).bind("mouseout",rbiyon);
		ini_width=target.attr("width");
		ini_height=target.attr("height");
		return target;

		function biyon(e){
			selector=e.target;
			after_width=selector.width*scale+"px";
			after_height=selector.height*scale+"px";
			       target.animate({width:after_width,height:after_height},duration,easing);
		}

		function rbiyon(e){
			target.animate({width:ini_width,height:ini_height},duration,easing);
		}

};

jQuery 要素の高さを取得

2010年04月22日(木)

http://www.atmarkit.co.jp/fdotnet/jqueryref/02attribute/attribute_14.html

要素の高さを取得するのは

height()、width()
innerHeight()、innerWidth()
outerHeight()、outerWidth()
outerHeight( true )、outerWidth( true )

があります。便利ですね。

それぞれ
・なにも含まない
・padding を含む
・border-width を含む
・margin を含む

となっていました。

jQuery aのイベントでリンクさせない処理2

2010年04月19日(月)

参考
http://semooh.jp/jquery/cont/doc/event/

eventオブジェクト.preventDefault()でブラウザの初期アクションをキャンセルできるそうです。
前述のreturn falseの方がお手軽な気がします。
使いどころだと思います。

$("#test a").click(function (e) {
 e.preventDefault();
}

http://blog.macaroniworks.net/2010/03/jquery-aのイベントでリンクさせない処理/

jQuery 1.4からのdelay()メソッドについて

2010年03月31日(水)

http://api.jquery.com/delay/

$('#foo').slideUp(300).delay(800).fadeIn(400);

使いそうなのでメモっておきます。
直感的で簡単なので、すぐに導入できそうです。

jQuery 知らなかった子要素の選択方法

2010年03月30日(火)

DesignReviver
http://designreviver.com/wp-content/uploads/2008/10/example.html

に下記の記述があったのですが、なにかよくわかりませんでした。

$("ul",this)

これは$(this)の中のul要素を選択する時などに使うと思われますが、
初めて見てしまいました。
知らないとはおっかないね。