Seemingly simple but I can't find the correct placement. I have the following function in my HTML head:
<script>
(function($) {
$.fn.writeText = function(content) {
var contentArray = content,
current = 0,
elem = this;
setInterval(function() {
if(current < contentArray.length) {
elem.text(elem.text() + contentArray[current++]);
}
}, 1000);
};
})(jQuery);
</script>
I call it in the body like:
<script>
// test getArray() method in external JS file
document.write(getArray());
$(document).ready(function($){
var contentArray = getArray();
$('#calculations').writeText(contentArray);
});
</script>
<h3>Fibonacci Sequence:</h3>
<p id='calculations'></p>
I can't find out where to place the '+ br /' to concatenate each writeText with a line break.
text()replaces the content, it does not add lines, is that the issue you're having ?