I have tried using the solution of this question to display fractions. The problem is I don't know how to make it so that it will work on dynamically generated fractions. Here is the jQuery code block:
$(document).ready(function() {
$('#main').on('click', '#startButton', function () {
$('#startButton').hide();
$('#main').html('<div class="progress">progress</div><hr><div class="questions"><span class="fraction">1/2</span></div><hr><div class="answers">answers</div>');
});
$('.fraction').each(function(key, value) {
$this = $(this);
var split = $this.html().split("/");
if(split.length == 2){
$this.html('<span class="top">'+split[0]+'</span><span class="bottom">'+split[1]+'</span>');
}
});
});
I realize that the .each() function does not work because it is passing an object into #main
. Here is a jsfiddle illustrating my problem. Click "placeholder for start button" to see the fraction