I was wondering if it was possible to change text dynamically in jQuery.
I want to display this in HTML —
A [dynamic animal name] is my favourite pet.
meaning that
[dynamic animal name]
should be inside an array of words, say
var wordArray = [cat, dog, cow]
How would i go about seperating the paragraphs into one that can be dynamically changed?
I was trying
<p>A <p id="special">[wordArray goes here]</p> is my favourite pet.</p>
but it turns out like this in html:
A cow
is my favourite pet.
meaning it breaks the whole line of words into 2 seperate sentences.
How do i make it go together?
Instead of
<p id="special">...</p>use a<span id=special"> ... </span>spanis an inline element and will not break the view.Another solution is to use css to make the
<p id="special">element inline: