<?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>omiga &#187; die</title>
	<atom:link href="http://omiga.org/blog/archives/tag/die/feed" rel="self" type="application/rss+xml" />
	<link>http://omiga.org/blog</link>
	<description>简单就好</description>
	<lastBuildDate>Mon, 06 Feb 2012 17:39:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>jQuery1.3:Live Events</title>
		<link>http://omiga.org/blog/archives/892</link>
		<comments>http://omiga.org/blog/archives/892#comments</comments>
		<pubDate>Fri, 16 Jan 2009 06:49:47 +0000</pubDate>
		<dc:creator>omiga</dc:creator>
				<category><![CDATA[前端开发]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[die]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[live]]></category>
		<category><![CDATA[unbind]]></category>

		<guid isPermaLink="false">http://omiga.org/blog/?p=892</guid>
		<description><![CDATA[jQuery 1.3中新增了两个“实时”事件处理方法——live,die，用于绑定和删除事件处理函数。这两个方法与之前的bind和unbind存在明显的区别。 live( type, fn ) Added in jQuery 1.3: Binds a handler to an event (like click) for all current &#8211; and future &#8211; matched element. Can also bind custom events. bind( type, [data], fn ) Binds a handler to one or more events (like click) for each matched element. Can also bind custom events. bind只能对当前的匹配对象绑定事件处理函数，而live不但能够对当前的匹配对象绑定事件处理函数，还能够对将来的匹配对象绑定事件处理函数。 例如： $("button").bind("click",function(){ 　　$(this).after("&#60;button&#62;click [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jquery.com/" target="_blank">jQuery</a> 1.3中新增了两个“实时”事件处理方法——live,die，用于绑定和删除事件处理函数。这两个方法与之前的bind和unbind存在明显的区别。</p>
<blockquote><p><strong><strong class="selflink">live</strong>( type, fn ) </strong></p>
<p>Added in jQuery 1.3<strong>:</strong> Binds a handler to an event (like click) for all current &#8211; and <strong>future</strong> &#8211; matched element.  Can also bind custom events.</p></blockquote>
<blockquote><p><strong><strong class="selflink">bind</strong>( type, <span class="optional">[</span>data<span class="optional">]</span>, fn ) </strong></p>
<p>Binds a handler to one or more events (like click) for each matched element.  Can also bind custom events.</p></blockquote>
<p>bind只能对当前的匹配对象绑定事件处理函数，而live不但能够对当前的匹配对象绑定事件处理函数，还能够对将来的匹配对象绑定事件处理函数。</p>
<p>例如：</p>
<pre>$("button").bind("click",function(){
　　$(this).after("&lt;button&gt;click me&lt;/button&gt;");
　}
);</pre>
<p>使用bind无法对后面创建的对象进行“click”事件处理函数的绑定。</p>
<p>而使用live则完全可以对将来的匹配对象进行事件处理函数的绑定：</p>
<pre>$("div").live("click",function(){
　　$(this).after("&lt;div&gt;div:click me&lt;/div&gt;");
　}
)</pre>
<p><a href="http://omiga.org/lab/live_events.html" target="_blank">查看Demo</a></p>
<p>附：<a href="http://omiga.org/jquery/" target="_blank">jQuery1.3中文API</a></p>
<hr />
<p><small>© omiga for <a href="http://omiga.org/blog">omiga</a>, 2009. |
<a href="http://omiga.org/blog/archives/892">Permalink</a> |
<a href="http://omiga.org/blog/archives/892#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://omiga.org/blog/archives/892&title=jQuery1.3:Live Events">del.icio.us</a>
<br/>
Post tags: <a href="http://omiga.org/blog/archives/tag/bind" rel="tag">bind</a>, <a href="http://omiga.org/blog/archives/tag/die" rel="tag">die</a>, <a href="http://omiga.org/blog/archives/tag/jquery" rel="tag">jQuery</a>, <a href="http://omiga.org/blog/archives/tag/live" rel="tag">live</a>, <a href="http://omiga.org/blog/archives/tag/unbind" rel="tag">unbind</a><br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://omiga.org/blog/archives/892/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

