我從一本書,我用來學習jQuery我修改了它一點點
<body>
<h4><i>More</i> Mitch Hedberg Quotes</h4>
<div>
<input type='submit' id='tmpQuote1' value='View Quote' />
</div>
<div>
<input type='submit' id='tmpQuote2' value='View Quote' />
</div>
<div>
<p id="paragraph"> some text that will disappear</p>
</div>
$(document).ready(
function() {
$('p').mouseover(
function(){
$(this).replaceWith("<p> the text changed to this text </p>");
}
);
$('input#tmpQuote1').click(
function($e) {
$e.preventDefault();
$(this).replaceWith(
"<p>\n" +
" I would imagine that if you could understand \n" +
" Morse code, a tap dancer would drive you crazy.\n" +
"</p>\n"
);
}
);
$('input#tmpQuote2').click(
function($e) {
$e.preventDefault();
$(this).replaceWith(
"<p>\n" +
" I'd like to get four people who do cart wheels \n" +
" very good, and make a cart.\n" +
"</p>\n"
);
}
);
這個HTML代碼基本上當我將鼠標懸停在末段它改變文本。 當我點擊這兩個按鈕,他們改變段落+文字。 迄今爲止很好。但是我遇到的問題是理解爲什麼當我將鼠標懸停在第一個&秒(新產生的)段落上時,鼠標懸停不起作用。 Jquery解析器中有沒有延遲?或者,也許我不知道這個$的工作原理。
感謝
這一個工程謝謝 – Marin