I have a function that splits each letter from a span text and wrap it into an em. It works but the first letter from the span is not wrapped. How can I wrap that letter also in em?
var newSplit = $("#selectable1 span.cica").text().split("").join("</em><em>");
For the text "Test", the initial code:
Would have produced an array ['T','e','s','t]
Calling join on the array inserts the separator between each array item, so you would end up with:
You then need to wrap the initial 'T' with a starting
<em> and close off with a
</em> on the final 't'
using window.parent you can get a reference to the parent of the iframe.
Is there anything that you want to achieve by nesting iframes? If yes, then you have to traverseup the tree using parent to get the topmost parent.
I've changed the code to something I found on jQuery examples and now it works. I can't figure it out why it did not work right the first time. Here is the new code if anyone have the same problem
var words = $("#selectable1 span.cica").text().split(""); var text = words.join("</em><em>"); $("#selectable1 span.cica").html("<em>" + text + "</em>");