[問題] 關於.this 的問題

看板Ajax作者 (央)時間14年前 (2012/02/23 06:01), 編輯推噓2(204)
留言6則, 4人參與, 最新討論串1/1
以下是我遇到的問題: 我有一筆XML 的資料,撈出丟給了 title, 然而程式一直走到 alert(msg).this; 的部分,都很正常是我要的資料。 但就在最後一行 jQuery(msg).this.appendTo('.info'); 我想把msg安插在.info的標籤裡面, 卻怎麼樣都顯示不出來, 請問我哪個環節出了錯了嗎? var title = m.find('vName').text(); var msg = '<div class="perview">'+title+'</div>'; $('.perview img').click(function() { //alert(msg).this; $('.info_content').fadeIn(); jQuery(msg).this.appendTo('.info'); }); -- Blog http://oao54bb.blogspot.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.240.35.35

02/23 08:47, , 1F
jQuery object 沒有 this property
02/23 08:47, 1F

02/23 08:47, , 2F
請試試 jQuery(msg).appendTo('.info');
02/23 08:47, 2F

02/23 18:30, , 3F
我有試過樓上大大的方法,但會將所有title 裡的資料印出
02/23 18:30, 3F

02/23 22:23, , 4F
$(msg).each(function(){$(this).appendTo('.info')});
02/23 22:23, 4F

02/24 04:37, , 5F
這個方法好像有點效,不過他會從點選後的資料開始印出全部
02/24 04:37, 5F

02/25 10:12, , 6F
$(".info").append(msg)
02/25 10:12, 6F
文章代碼(AID): #1FHMMqa7 (Ajax)
文章代碼(AID): #1FHMMqa7 (Ajax)