Feeling stupid here. The .click()
function is not firing and I have no idea why not. The code is really as simple as below. Note: the span
s in the .selector-book
div
are dynamically loaded by a previous function. Any help is appreciated, as always.
HTML:
<div id="selector-book" class="selector-book">
<span class="book-name" data-book-number="0"></span>
<span class="book-name" data-book-number="1"></span>
<span class="book-name" data-book-number="2"></span>
<span class="book-name" data-book-number="3"></span>
...
</div>
JS:
$(document).ready(function() {
$('.selector-book span').click(function() {
console.log('test');
$('.selector-chapter').html('');
var p = $(this).data('book-number');
for (var i = 0; i < myBible[p][2]; i++) {
$('.selector-chapter').append('<span>' + i + '</span>');
}
});
});