Skip to content

Instantly share code, notes, and snippets.

Created June 3, 2017 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/221a612fafce4bd8333ff1744043cd3f to your computer and use it in GitHub Desktop.
Save anonymous/221a612fafce4bd8333ff1744043cd3f to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/mizugucomu
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<div id="section1" class="section">
<button type="button" id="btn1">First Button</button>
<span id="sp1">0</span>
</div>
<div id="section2" class="section">
<button type="button" id="btn2">Second Button</button>
<span id="sp2">0</span>
</div>
<div id="section3" class="section">
<button type="button" id="btn3">Third Button</button>
<span id="sp3">0</span>
</div>
<script id="jsbin-javascript">
$.fn.parse = function() {
return this.each(function() {
var spn = $(this).find("span");
btn = $(this).find("button");
btn.on("click", function(e) {
var n = parseFloat(spn.html());
n += 1;
spn.html(n);
btn.html(btn.html() + "(clicked)");
});
});
}
$(".section").parse();
</script>
<script id="jsbin-source-javascript" type="text/javascript">$.fn.parse = function() {
return this.each(function() {
var spn = $(this).find("span");
btn = $(this).find("button");
btn.on("click", function(e) {
var n = parseFloat(spn.html());
n += 1;
spn.html(n);
btn.html(btn.html() + "(clicked)");
});
});
}
$(".section").parse();</script></body>
</html>
$.fn.parse = function() {
return this.each(function() {
var spn = $(this).find("span");
btn = $(this).find("button");
btn.on("click", function(e) {
var n = parseFloat(spn.html());
n += 1;
spn.html(n);
btn.html(btn.html() + "(clicked)");
});
});
}
$(".section").parse();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment