且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery .load()使内容在加载后不可点击

更新时间:2023-01-13 10:30:18

jQuery .click事件不是实时事件,因此它将仅使已分配给click的项目成为可单击事件.一旦这些项目被刷新,移除或引入了新项目,刷新的项目将不会具有click事件,而新项目将不会具有click事件.

The jQuery .click event is not a live event, so it will only make items it has been assigned to clickable. Once those items are refreshed, removed or new items come in, the refreshed items won't have the click event and new items won't have the click event.

您将要使用 jQuery .on 事件,它是.的替代.现场直播.这样,当内容刷新时,它们仍然会附加一个click事件.

You'll want to use the jQuery .on event, which is the replacement for the .live event. That way when the contents refresh, they'll still have a click event attached.

另一种选择是每当内容刷新时分配点击事件.

The other option is to assign the click event whenever the content refreshes.