zoukankan      html  css  js  c++  java
  • 定义文字样式-插件

    今天抽时间写一个定义文字样式的插件:

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>word</title>
    </head>
    <body>
    <div class="word">
    <p>文字插件文字插件文字插件文字插件文字插件</p><br />
    <p>文字插件文字插件文字插件文字插件文字插件</p><br />

    <p>文字插件文字插件文字插件文字插件文字插件</p><br />
    <p>文字插件文字插件文字插件文字插件文字插件</p><br />

    <p>文字插件文字插件文字插件文字插件文字插件</p><br />
    <p>文字插件文字插件文字插件文字插件文字插件</p><br />

    <p>文字插件文字插件文字插件文字插件文字插件</p><br />
    <p>文字插件文字插件文字插件文字插件文字插件</p><br />

    <p>文字插件文字插件文字插件文字插件文字插件</p><br />
    <p>文字插件文字插件文字插件文字插件文字插件</p><br />


    </div>


    <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">
    (function($){
    $.fn.extend({
    aWords:function(word){
    var defaults={
    color:"black",
    backgroundColor:"#f2f2f2",
    paddingLeft:10
    };
    var word=$.extend(defaults,word);
    return this.each(function(obj){
    var obj=$(this);
    var o=word;
    var item=$("p",obj);
    item.hover(function(){
    $(this).css(
    {color:o.color},
    {backgroundColor:o.backgroundColor}
    );
    $(this).animate(
    {paddingLeft:o.paddingLeft},
    {queue:false,duration:300}
    )
    },function(){
    $(this).css(
    {color:""},
    {backgroundColor:""}
    );
    $(this).animate(
    {paddingLeft:"0"},
    {queue:false,duration:300}
    )
    })
    })
    }
    })
    })(jQuery);

    //调用代码
    $(document).ready(function(){
    $(".word").aWords({
    paddingLeft:"10px",
    color:"red"
    })
    })
    </script>

    </body>
    </html>

  • 相关阅读:
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    线性表——数组实现
    this指针与const成员函数
    类对象拷贝是不是赋值操作??
    你真的理解内联函数吗?
    名字查找先于类型检查:函数重载与作用域
    谈谈函数调用
    推荐形参使用常量引用:void func(const T &);
  • 原文地址:https://www.cnblogs.com/fs521cw/p/5180327.html
Copyright © 2011-2022 走看看