简体   繁体   English

如何与已加载的php文件进行交互?

[英]How do I interact with a loaded php file?

$('#offer').click(function() {
    $("<br><br><strong>Please wait...</strong>").appendTo($("#results"));
    $('#results').load("fulfill.php");

});

$("#employees tr").live("click", function() {
    var id = $(this).find('id').attr('id');
    alert(id);

I have a dynamic table that is in the fulfill.php file. 我在complement.php文件中有一个动态表。 When it loads, I want to be able to click on any of the rows and get the id value. 加载时,我希望能够单击任何行并获取id值。 It loads fine and I can click with a response. 它加载正常,我可以点击以回复。 I cannot get the id value. 我无法获取ID值。

Change this line 更改此行

 var id = $(this).find('id').attr('id');

to

var id = $(this).attr('id');

If you want the ID of the tr . 如果您想要tr的ID。

And you should consider using $.on as $.live is depreciated now. 您应该考虑使用$ .on,因为$ .live现在已贬值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM