Current location - Recipe Complete Network - Complete cookbook - Html and html5 click on the menu to display pictures. How to achieve this?
Html and html5 click on the menu to display pictures. How to achieve this?
If you want to reduce the size of the web page and load it in real time, you can only use js.

The following is an example. After measurement, you can optimize it as needed:

& lt! DOCTYPE html & gt

& lthtml & gt

& lthead & gt

< title & gt menu

& ltscript type = " text/JavaScript " & gt;

Function chgimg(src)

{

var img = document . getelementbyid(" img ");

img.src=src+"。 jpg ";

}

& lt/script & gt;

& lt/head & gt;

& ltbody & gt

& ltdiv & gt

& ltp & gt& ltimg src = " a 1 . jpg " id = " img "/& gt; & lt/p & gt;

& ltp & gt& ltul & gt& ltLi onclick = " chg img(' a2 ');" & gta</ Li> & ltlionclick = "chgimg ('a3');" & gtb</ Li>& lt Li onclick = "chgimg ('a1');" & gtc</ Li>& lt/ul & gt;; & lt/p & gt;

& lt/div & gt;

& lt/body & gt;

& lt/html & gt;