无法在jQuery中处理从ajax请求插入的数据

在调用服务器并转动数据后,它返回到表中。 我使用jQuery的.html()语法将其插入页面。 之后,数据出现在页面中,但我无法使用jQuery操作它。

inheritance人代码:

  testJavaScript   function makeTable(data) { var htmlOut = ""; for (x in data) { htmlOut += ""; for (y in data[x]) { htmlOut += ""; } htmlOut += ""; } htmlOut += "
"+data[x][y]+"
"; return htmlOut; } function getValue() { return $("#MyText").val() } $(document).ready(function () { $("img").hover(function () { //This dosent work on the data returned from the server $(this).hide(1000) //$(this).css({'background-color': '#357EC7', 'border': '2px solid #2B60DE'}); }) $("#populateDrop").click(function () { $.getJSON('http://127.0.0.1:5000/ajaxTest/json?num='+ getValue() +'&callback=?', function(data) { $(".result").html(makeTable(data.data)); }) }) })
Populate!

您需要使用live代替动态数据:

 $("img").live('hover', function () { $(this).hide(1000); }); 

更多信息: