<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>刘钢的博客 - 我是UED &#187; simpletip</title>
	<atom:link href="http://www.iamued.com/tag/simpletip/feed" rel="self" type="application/rss+xml" />
	<link>http://www.iamued.com</link>
	<description>http://www.IamUED.com</description>
	<lastBuildDate>Wed, 18 Jan 2012 02:51:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>[原创]jQuery SimpleTip Plugin1.0</title>
		<link>http://www.iamued.com/qianduan/1144.html</link>
		<comments>http://www.iamued.com/qianduan/1144.html#comments</comments>
		<pubDate>Sun, 10 Jan 2010 12:48:12 +0000</pubDate>
		<dc:creator>RichieLiu</dc:creator>
				<category><![CDATA[JavaScript脚本]]></category>
		<category><![CDATA[前端开发]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[simpletip]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://www.iamued.com/?p=1144</guid>
		<description><![CDATA[公司项目由于一些历史原因 所以采用Jquery的库 一直没有用jquery的插件机制写过代码,于是就趁热打铁研究了一下jq的插件机制 非常简单的一个效果 暂且命名为jQuery SimpleTip Plugin1.0吧 [查看DEMO] [下载源码] 新增了 template的机制 Demo -2010/9/7 插件功能很简单：见下图 就是一个鼠标提示的tip效果 可以自定义宽度 使用方法： 在需要使用该插件的页面插入如下依赖 具体路径请自行修改 分别是：JQuery1.32 本插件核心代码 和本插件的css样式 插件使用： 核心代码分析： 就到这里吧：） [查看DEMO] [下载源码]新增了 template的机制 Demo -2010/9/7 转载请注明来源：）]]></description>
			<content:encoded><![CDATA[<p>公司项目由于一些历史原因 所以采用Jquery的库<br />
一直没有用jquery的插件机制写过代码,于是就趁热打铁研究了一下jq的插件机制<br />
非常简单的一个效果 暂且命名为<a href="http://www.iamued.com/demo/simpletip/index.html" target="_blank">jQuery SimpleTip Plugin1.0</a>吧<br />
<a href="http://www.iamued.com/demo/simpletip/index.html" target="_blank">[查看DEMO]</a> <a href="http://www.iamued.com/demo/simpletip/simpletip_iamued.rar" target="_blank">[下载源码]</a><br />
<a href="http://www.iamued.com/demo/simpletip/template/" target="_blank"><span style="color: #ff0000;">新增了 template的机制 Demo -2010/9/7</span></a><br />
插件功能很简单：见下图<br />
<img class="alignnone size-full wp-image-1145" title="tip1" src="http://iamued-wordpress.stor.sinaapp.com/uploads/2010/01/tip1.jpg" alt="tip1" width="168" height="88" /><br />
就是一个鼠标提示的tip效果 可以自定义宽度</p>
<p><strong>使用方法：</strong><br />
在需要使用该插件的页面插入如下依赖 具体路径请自行修改<br />
分别是：JQuery1.32 本插件核心代码 和本插件的css样式</p>
<pre class="brush: xml; title: ; notranslate">
&lt;script src=&quot;jquery/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;simpletip/jquery.tip-min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;link href=&quot;simpletip/SimpleTip.css&quot; rel=&quot;stylesheet&quot;/&gt;
</pre>
<p><strong>插件使用：</strong></p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function(){//jq的页面载入事件
    $(&quot;#tip2&quot;).tip({ //获取目标元素
    width: 100,//自定义宽度 也可以不设定此项
    text: &quot;&lt;span class='icon01'&gt;&lt;/span&gt;宽度：100px 是自定义的&quot;//提示内容 可以包含html代码
    });
})
</pre>
<p><strong>核心代码分析：</strong><br />
<span id="more-1144"></span></p>
<pre class="brush: jscript; title: ; notranslate">
(function($){//建立闭包
	var _tip;//创建提示对象
    $.fn.tip = function(options){//jq插件机制的核心函数$.fn
        var defaults = {	//默认参数
			width:300,
            text: &quot;这里是提示文字&quot;
        };
        var opts = $.extend(defaults, options);//参数合并 具体参见jq手册
        this.bind(&quot;mouseover&quot;, function(event){//给目标对象绑定事件
            showtip(event, opts);
        });
        this.bind(&quot;mouseout&quot;, function(event){
            _tip.hide();
        });
        this.css(&quot;cursor&quot;, &quot;pointer&quot;);//目标对象的鼠标样式
    };
    function showtip(event, opts){//显示提示层方法
        target = $(event.target);//获取事件触发的对象
        if (!_tip) {//如果提示对象不存在
            _tip = $(&quot;&lt;div/&gt;&quot;);//创建一个div element
            _tip.addClass(&quot;tip&quot;).css(&quot;width&quot;, opts.width).appendTo($(&quot;body&quot;));//根据参数设定宽度 插入到body中
            _tip.bind(&quot;mouseenter&quot;, function(event){//给提示对象绑定事件 这里使用mouseenter jq已经做了兼容
                $(this).show();
            });
            _tip.bind(&quot;mouseleave&quot;, function(event){//给提示对象绑定事件 这里使用mouseleave jq已经做了兼容
                $(this).hide();
            });
        }
        _tip.css(&quot;width&quot;, opts.width);//提示对象的宽度
        _tip.html(&quot;&lt;div&gt;&quot;+opts.text+&quot;&lt;/div&gt;&quot;);//提示对象的内容
        _tip.append($(&quot;&lt;iframe class='ie6iframe'&gt;&lt;/iframe&gt;&quot;).css(&quot;width&quot;, _tip.width()).css(&quot;height&quot;, _tip.outerHeight(true)));
		//建立遮罩层
        _tip.css(&quot;position&quot;, &quot;absolute&quot;).css(&quot;top&quot;,target.offset().top + target.height() - 3).css(&quot;left&quot;,target.offset().left);//提示对象定位
        _tip.show();
    };
    })(jQuery);
</pre>
<p>就到这里吧：）<br />
<a href="http://www.iamued.com/demo/simpletip/index.html" target="_blank">[查看DEMO]</a> <a href="http://www.iamued.com/demo/simpletip/simpletip_iamued.rar" target="_blank">[下载源码]</a><a href="http://www.iamued.com/demo/simpletip/template/" target="_blank"><span style="color: #ff0000;">新增了 template的机制 Demo -2010/9/7</span></a><br />
转载请注明来源：）</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iamued.com/qianduan/1144.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

