javascript - How to implement batch click events in Angular2?
世界只因有你
世界只因有你 2017-06-26 10:50:54
0
1
772

1. You need to set click events for all images, including the img tag in the html that is added later.
2. How to add click events to all img.
3. Is there a method similar to $().on?

世界只因有你
世界只因有你

reply all(1)
迷茫
var imgs = ..... // 获取你要的img标签

Array.prototype.forEach.call(imgs, function (img) {
    img.addEventListener('click', function () {
        // do something
    })
})

As long as the code is written in js, all native methods can be used.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!