uupaa.js 0.7依存。
uu.js + uu.query.js
(function(){ var toggle_image = function(node){ var arr = node.getAttribute('toggleImage').split(','); switch(node.width){ case Number(arr[0]): node.width = arr[2]; node.height = arr[3]; break; case Number(arr[2]): node.width = arr[0]; node.height = arr[1]; break; default: node.width = arr[0]; node.height = arr[1]; break; }; }; var scan = function(){ var image_nodes = uu.query('.toggleImage'), image_node, i=-1, arr=[]; while(image_node = image_nodes[++i]){ uu.event(image_node, 'click', function(evt){toggle_image(evt.target||window.event.srcElement)}); }; }; //toggle_image = {}; //toggle_image.scan = scan; uu.ready(scan); })();
此んな風に書く。
<html> <head></head> <body> <script src="uupaa.js"></script> <script src="toggle_image.js"></script> <img src="haibane27.png" width="317" height="250" class="toggleImage" toggleImage="317,250,1267,1000"/><br/> <img src="haibane27.png" width="317" height="250" class="toggleImage" toggleImage="317,250,1267,1000"/> </body> </html>