jQuery onclick all images in body

后端 未结 3 726
说谎
说谎 2021-01-22 18:02

English isnt my native language so bear with me.

Im trying to make it so that when a user clicks any image on my site a gallery sort of div will become visible containin

3条回答
  •  情歌与酒
    2021-01-22 18:16

    The issue is with your selector. The '>' selector specifies an immediate child . The selector that @dstroy is suggesting would simply grab any image on the entire page. This, though, may not be what your are trying to accomplish.

    I'm assuming you have some form element (let's assume a DIV with ID 'gallery') that contains all of the images you are interested in. You could then use

    var images = $("#gallery img");
    

    This way, icons and 'chrome' images won't be displayed on the background.

提交回复
热议问题