我有一個var,我正在嘗試編輯html。我想將類「文件」的UL移動到它自己的var,然後從數據var中移除它。Jquery find()元素,然後刪除它
我有這個目前爲止,但做錯了。我似乎無法理解它。
var data = '<ul class="dirs"><li class="d"><a href="#" rel="/Games/">Games</a></li><liclass="d"><a href="#" rel="/Log/">Log</a></li></ul><ul class="files"><li class="f"><a href="#">fubar.txt</a></li><li class="f"><a href="#">fubar2.txt</a></li></ul>';
var files = $(data).find("UL.files").html();
預期結果:
data = '<ul class="dirs"><li class="d"><a href="#" rel="/Games/">Games</a></li><li class="d"><a href="#" rel="/Log/">Log</a></li></ul>';
files = '<ul class="files"><li class="f"><a href="#">fubar.txt</a></li><li class="f"><a href="#">fubar2.txt</a></li></ul>';
感謝
爲什麼UL在'找到( 「UL.files」)'資本?另外,你會得到什麼樣的行爲? –