Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<img src="http://www.w3school.com.cn/i/eg_smile.gif">
  <script>
    //set bind init data
    $('img').data('state', 0);
    
    //click event
    $('img').click(function(){
      var state = $('img').data('state');
      alert(state);
      if(state == 0){
        $("img").attr("width","280");
        $(this).data('state',1);
      }else{
        $(this).data('state',0);
        $("img").attr("width","180");
      }
      
  })
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers