Skip to content

Instantly share code, notes, and snippets.

@banyan
Created February 14, 2010 16:03
Show Gist options
  • Select an option

  • Save banyan/304107 to your computer and use it in GitHub Desktop.

Select an option

Save banyan/304107 to your computer and use it in GitHub Desktop.
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>gangr</title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="./css/default.css" type="text/css" media="all" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="expires" content="0" />
<script type="text/javascript" src="./js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="./js/application.js"></script>
<script type="text/javascript">
$(function() {
jQuery.scope = function(target,func){ return function() { func.apply(target,arguments);}};
var setOptions = function(self) {
var opt = {
val: self.val()
};
return opt;
}
$('.buttons').click(function() {
var opt;
$.scope(this, opt = setOptions($(this)));
console.log(opt.val);
});
});
</script>
</head>
<body>
<h1>This is a jQuery scope testing</h1>
<input type="button" id="button_1" value="button_1"/>
<input type="button" id="button_2" value="button_2"/>
<div>
<input type="button" class="buttons" value="buttons_1"/>
<input type="button" class="buttons" value="buttons_2"/>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment