sách gpt4 ăn đã đi

javascript - jQuery:思考 on() 而不是 live() ,在动态生成的东西上传播

In lại Tác giả: Walker 123 更新时间:2023-11-30 13:01:05 26 4
mua khóa gpt4 giày nike

得到这个 HTML:






mother 在页面中,但是 children,lựa chọninput 都是动态生成的

试着用类似的方式给他们打电话:

$('body').on('blur change','#mother input, #mother select',function(){
alert($(this).attr('id'))
})

Javascript 什么都没说..

如何使用 on() thay vì live() 来最好地做到这一点? ...因为使用 live() 更容易理解。

Cảm ơn.

câu trả lời hay nhất

.live() 已弃用并删除,根本不要使用它 version deprecated: 1.7, removed: 1.9

像这样使用

$('body').on('blur change', '#mother input, #mother select', function () {
alert($(this).attr('id'));
});

关于javascript - jQuery:思考 on() 而不是 live() ,在动态生成的东西上传播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17388961/

26 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress