Is there a way to get onclick to work on first click? I have multiple instances on the same page. Here is my code:
<script> function showMoreOrLess(thisObj) { var caption = thisObj.innerHTML; var otherObj = thisObj.parentElement.previousElementSibling; if (caption == "Read more") { otherObj.style.display = "inline"; thisObj.innerHTML = "Read less"; } else { otherObj.style.display = "none"; thisObj.innerHTML = "Read more"; } } </script> <p><a onclick="showMoreOrLess(this);">Read more </a></p>
Remove the space
<a onclick="showMoreOrLess(this);">Read more </a>
to
<a onclick="showMoreOrLess(this);">Read more</a>
1.4m articles
1.4m replys
5 comments
57.0k users