/*** Here we will briefly introduce how to use JavaScript to operate HTML elements. * We can use document. getelementbyid ("998"); get an element on a webpage */window. onload = Init; function Init () {var BTN = document. getelementbyid ("998"); // obtain a button var IMG = document. getelementbyid ("img1"); // obtain an IMG image. src = "JS/c.jpg"; // use Code Set the image SRC to be similar to IMG. title = "image flip"; // use a string to assign an IMG value directly. classname = "hide"; alert (IMG. onclick); // you can view IMG information generated by HTML. onclick = onclick; // attribute and event are different settings. You need to assign an IMG function. onmouseover = onmouseover; IMG. onmouseout = onmouseout; BTN. innerhtml = "show image"; BTN. onclick = btn_click;} function onclick (event) {alert (1234);} function onmouseover (event) {This. src = "JS/B .jpg"; // remember to add this. Otherwise, SRC is the default attribute of a Windows Object and cannot start. Function onmouseout (event) {This. src = "JS/c.jpg"; // The attribute value must be explicitly specified, just like the this pointer in Java. Attributes depend on objects. Similarly, this method also depends on the object.} function btn_click () {// The parameter cannot be passed for the event method. It looks like. We can use this to call the current object. If ("show image" = This. innerhtml) {var IMG = document. getelementbyid ("img1"); // if you want to use other elements, we can obtain IMG. classname = "show"; this. innerhtml = "Hide image";} else if ("Hide image" = This. innerhtml) {var IMG = document. getelementbyid ("img1"); IMG. classname = "hide"; this. innerhtml = "show image ";}}