jQuery.each()
Variations on jQuery.each()
by b9chris
HTML
<span>hi</span> <span>bye</span> <span>hello?</span>
<button>Run</button>
<div id=output></div>
CSS
body {
font-family: Verdana;
}
button {
display: block;
}
JavaScript
$('button').click(function() {
// Demo code
$('span').each(function(i, tag) {
say(i + ': ' + tag.innerHTML);
});
});
function say(s) {
var output = $('#output');
output.html(output.html() + s + '<br/>');
}