I'm using the following code to create fractions:
<script type='text/javascript'>
$(document).ready(function () {
$('.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>')
}
});
});
</script>
If I have the following code in my body, it successfully formats as a fraction:
<span class="fraction">4/1</span>
If, however, I include a tag, as illustrated below, the function no longer works
<span class="fraction"><strike>4</strike>/1</span>
How can I fix this? Thanks!
` is an element not supported in HTML5, use `– zer00ne Apr 28 '16 at 01:35` or ``...These elements will put a line right thru that 4. It won't look like `4/1`.tag still invalidates the fraction format.– J Doe Math Apr 28 '16 at 01:35` is HTML4 if you are asking jQuery to parse a string as if is HTML, perhaps you should use valid tags. See my last comment.– zer00ne Apr 28 '16 at 01:43