2012年12月22日土曜日

jQuery purupuru.js の作り方

こんばんは みたび Fuya です。
きょうはjQueryでプラグインを作ったので紹介したいと思います.
あなたは、jQueryでぷるぷるさせたい事ありますか?
とくに冬至は入力フォームをプルプルさせたい衝動に駆られますよね。
jQueryのプラグインは,2種類あります.
  • $('selector').hoge()
  • $.hoge()
今回は,特定のオブジェクトをプルプルさせたいので,前者の呼び出し方法のやつにします.

さっそく作ってみよう

(function($){
$.fn.purupuru=function(){
        return this;
    };
})(jQuery);
これで何もしないjQueryプラグイン $(selector).purupuru(); の完成です.
次にプルプルさせます.

....
    $.fn.purupuru=function(){

        this.css('position','relative');

        for (var i = 0; i< 5; i++) {
            this.animate(
            {
                left: "6px"
            },
            20
            ).animate(
            {
                left: "-6px"
            },
            20
            );
        }
        this.animate(
        {
            left: "0px"
        },
        10,
        function() {
            this.css('position', '');
            this.css('position', '');
        }
        );
....
よいプルプルらいふを!

13 件のコメント:

  1. I found your blog while I was webs writing to find the above information. Your writing has helped me a lot. I'll write a nice post by quoting your post.

    한국야동

    返信削除

  2. I am a fan of reading to add insight to information. Thank you for this great blog. this is here, the few months I am visiting and following you. What I really like about you is that your writing style.

    일본야동


    返信削除
  3. I found your blog while I was webs writing to find the above information. Your writing has helped me a lot. I'll write a nice post by quoting your post.


    일본야동

    返信削除
  4. I have taken your writing very well. Where can I get this information? I want to write good writing like you. Would you like to be a guest blogger on my website?

    한국야동

    返信削除
  5. I appreciate you taking time to share such valuable information. I had no clue on some of the things you mentioned earlier, thanks!

    토토사이트
    온라인카지노
    파워볼사이트
    카지노사이트

    返信削除
  6. Of course, what a fantastic blog and instructive posts, I definitely will bookmark your blog. All the Best!

    스포츠토토
    토토
    안전놀이터
    토토사이트

    返信削除
  7. I went over this internet site and I conceive you have a lot of superb information, bookmarked (:.

    토토사이트
    바카라사이트
    파워볼게임
    카지노사이트

    返信削除
  8. I’m going to read this. I’ll be sure to come back. thanks for sharing. 토토사이트

    返信削除
  9. I’ve learn several good stuff here. Definitely value bookmarking for revisiting. I wonder how so much effort you set to create one of these magnificent informative site. 파워볼

    返信削除
  10. This is another excellent post that I thoroughly liked reading. It is not every day that I am given the opportunity to witness something like this. subway surfers shell shockers

    返信削除
  11. I really like this topic, please mention it more heardle

    返信削除
  12. You there, this is really good post here. Thanks for taking the time to post such valuable infrmation.
    Okbet Online Gambling Ph

    返信削除