以下是我写的javascript块:
$(function(){
$("#schoolBagBtn").click(function(){
$.ajax({
url:"./php/get.php",
}).done(function(data){
$("#schoolBagList").html(data);
$(".schoolBagListItem").draggable();
});
});
});
ajax函数工作正常,#schoolBagList中的HTML代码已更改。
但是,$(".schoolBagListItem").draggable();
不起作用。
每次运行此javascript时,控制台日志中都会显示错误消息Uncaught TypeError: undefined is not a function at line 8
。
以下是从ajax调用返回的数据。
<li id="CRS00001" class="list-group-item list-group-item-success">ITP4505</li>
<li data-link="./emptyTeachingBook.pdf" id="MAT00001" class="list-group-item col-sm-offset-1 schoolBagListItem">Empty Teaching Book</li>
<li id="CRS00002" class="list-group-item list-group-item-success">ITP4506</li>
<li id="FDR00000" class="list-group-item list-group-item-info">Testing Folder 1</li>
<li data-link="./testingLink.pdf" id="FIL00000" class="list-group-item col-sm-offset-1 schoolBagListItem">Empty File 1</li>
<li id="FDR00001" class="list-group-item list-group-item-info">Testing Folder 2</li>
<li data-link="./emptyFile2.pdf" id="FIL00002" class="list-group-item col-sm-offset-1 schoolBagListItem">Empty File 2</li>
<li data-link="./file/251826_483198608361706_766265894_n.jpg" id="FIL00003" class="list-group-item col-sm-offset-1 schoolBagListItem">251826_483198608361706_766265894_n.jpg</li>
<li id="FDR00009" class="list-group-item list-group-item-info">A</li><li data-link="./file/Beautiful-Water-Line.jpg" id="FIL00005" class="list-group-item col-sm-offset-1 schoolBagListItem">Beautiful-Water-Line.jpg</li>
<li data-link="./file/65377_600883856649979_72587957_n.jpg" id="FIL00006" class="list-group-item col-sm-offset-1 schoolBagListItem">65377_600883856649979_72587957_n.jpg</li>
<li id="FDR00010" class="list-group-item list-group-item-info">B</li>
<li id="FDR00011" class="list-group-item list-group-item-info">C</li><li id="FDR00015" class="list-group-item list-group-item-info">Test</li>
<li id="FDR00016" class="list-group-item list-group-item-info">Test</li>
<li id="FDR00017" class="list-group-item list-group-item-info">Test</li>
有人可以帮忙吗?