Let’s say I’ve a few
<p> Hello </p>
<p> Hello </p>
<p> Hello </p>
<p> Hello </p>
I want to replace one “Hello” by “Good bye”.
So => $('p')[2].html('Good Bye');
It is not working why? Why should I must use the eq: selector?
It’s working when I do that
$('p:eq(3)').html('Good bye')
You are trying to use
html()methodwith javascript objectwhich is supposed to be used with jQuery object, you can useinnerHTMLwith javascript object so you need this,Live Demo