<spaning> individual characters, not just elements - help
Hi guys,
I'm trying to put <span>'s around individual characters. Here's what I have so far, but can't seem to tie it up properly. Alert testing each letter works fine; just can't seem to be able to use the wrap function at this stage..?
Can anyone shed any light?
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var stringBody = $('body > *').text();
var stringBodyLength = $('body > *').text().length;
var randomNumber = Math.floor(Math.random()*stringBodyLength);
for (var i = 0; i < stringBodyLength; i++){
var foo = stringBody.charAt(i);
// alert(foo);
foo.wrap('span></span>');
}
});
</script>
Thanks,