Skip to content

Instantly share code, notes, and snippets.

@jiangrongyong
Created July 24, 2012 14:48
Show Gist options
  • Select an option

  • Save jiangrongyong/3170390 to your computer and use it in GitHub Desktop.

Select an option

Save jiangrongyong/3170390 to your computer and use it in GitHub Desktop.
about this in js
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<a id="btn1" href="javascript:void(0);">btn1</a>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="index.v2.js" type="text/javascript"></script>
</body>
</html>
var clicky = {
wasClicked: function() {
console.log('wasClicked');
},
addListeners: function() {
var self = this;
$('#btn1').click(function() {
self.wasClicked();
console.log(self);
console.log(this);
});
},
loop: function() {
var self = this;
$('script').each(function() {
console.log(this);
console.log(self);
});
}
};
clicky.loop();
clicky.addListeners();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment