2011-05-27 73 views
0

我使用這個現有的DOM元素:,當它不應該.live工程和.bind不起作用它應該

function questionsForm() { 
    $("form[name='qc']:last").bind("focus", newTextLine); 
} 

,它不工作,但是當我更換.bind.live它的工作原理 這是那裏的手柄是假設的工作HTML:

<body> 

    <div id="screen"> 
     <div id="form"> 
      <div id="insertQuestions"> 
       <form id="qc" name="qc"> 
       <h2>Create New Question!</h2> 
       <div id="question">Question: <input type="text" name="Question" /></div><!--question--> 
       <input type="submit" value="Submit" /> 

爲什麼呢? jQuery 1.6

+0

什麼jQuery版本? – Neal 2011-05-27 14:59:03

+0

jQuery 1.6,更多字符發佈的問題.. :) – ilyo 2011-05-27 15:01:47

回答

0

bind只添加事件處理程序。和trigger運行它。

live既增加了處理程序,並運行它

側面說明

你爲什麼不只是通過表單的ID選擇?

$("form#qc").bind("focus", newTextLine); 
+0

他們使用描述爲相同:'$('selector')。bind/.live(「event」,function)' – ilyo 2011-05-27 15:04:11

+0

@IlyaD你是什麼來源? – Neal 2011-05-27 15:04:51

+0

@Neal,jQuery文檔:http://api.jquery.com/bind,http://api.jquery.com/live – ilyo 2011-05-27 15:06:49