Create a gist now

Instantly share code, notes, and snippets.

anonymous /index.html
Created Jun 3, 2017

What would you like to do?
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