onclick on a image to navigate to another page using Javascript

后端 未结 4 2060
刺人心
刺人心 2020-12-13 14:27

I am getting warmed up with Javascript so I am trying something on my own. I am searching for a onclick function, where I have thumbnail images in my index.html page, and wh

4条回答
  •  失恋的感觉
    2020-12-13 15:18

    Because it makes these things so easy, you could consider using a JavaScript library like jQuery to do this:

    
    

    Basically, it attaches an onClick event to all images with class thumbnail to redirect to the corresponding HTML page (id + .html). Then you only need the images in your HTML (without the a elements), like this:

    bottle
    glass
    

提交回复
热议问题