Created
June 3, 2017 02:25
-
-
Save anonymous/221a612fafce4bd8333ff1744043cd3f to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/mizugucomu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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