Sublime Text
<!DOCTYPE html> <html> <head> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.0.min.js"></script> <style type="text/css"> img{border:1px solid black;} </style> </head> <body> <button type="button">Click here</button> <p><img src="../image/troll-face.png" height="80" width="80"></p> <p><img src="../image/troll-face.png" height="80" width="80"></p> <p><img src="../image/troll-face.png" height="80" width="80"></p> <script> $(document).ready(function(){ $("button").click(function(){ $("img").attr("width",function(a,b){ if(a==0){return b;} if(a==1){return 200;} if(a==2){return b*2;} }); }); }); </script> </body> </html>
<!DOCTYPE html> <html> <head> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.0.min.js"></script> <style type="text/css"> img{border:1px solid black;} </style> </head> <body> <button type="button">Click here</button> <p><img src="../image/troll-face.png" height="80" width="80"></p> <p><img src="../image/troll-face.png" height="80" width="80"></p> <p><img src="../image/troll-face.png" height="80" width="80"></p> <script> $(document).ready(function(){ $("button").click(function(){ $("img").attr("width",function(a,b){ if(a==0){return b;} if(a==1){return 200;} if(a==2){return b*2;} }); }); }); </script> </body> </html>