我裏面的文字股利:jQuery的多行文字問題
<div>A description of dreamstill. It is a music site that is social and other stuff where you cando this and that and pretty much anything that your heart allows. This is probably as long as the description will get.</div>
然後我提取文本,並堅持它作爲一個data-url
屬性的形象:
var desc = div.text();
div.replaceWith('<img class="center" src='+url+' data-desc=' + desc + ' />');
的問題是圖像正在生成像這樣:
<img class="center" src="http://featherfiles.aviary.com/2011-09-09/aae3b22a952841cd9c0d6a26a5867325.png" data-desc="A" description="" of="" dreamstill.="" it="" is="" a="" music="" site="" that="" social="" and="" other="" stuff="" where="" you="" cando="" this="" pretty="" much="" anything="" your="" heart="" allows.="" probably="" as="" long="" the="" will="" get.="">
我在做什麼錯在這裏?
這是否工作?我認爲第二個jQuery函數的參數是context元素 – jimbojw
是的,它被添加到1.4中,你可以在這裏看到它:http://api.jquery.com/jQuery/#jQuery2 as「jQuery(html,props)」 – loganfsmyth
+ 1.發揮先生 - 我不知道。:) – jimbojw