i wants to set focus on the parent div when someone click on the link how can i
<li class="active">
<a href="#about">Link to the parent div</a>
</li>
<div id="#parent">
<div id="about">dummy data</div>
<div id="news">dummy data</div>
</div>
Just use
document.getElementById('parent').focus(). See the updated jsFiddle.But what is supposed to happen when the div gets the focus? Divs don’t change anything when they get focus!
Edit:
If you want the
<a>to scroll the document to the top ofparentwhen clicked, this is what you need:document.body.scrollTo(0, document.getElementById('parent').offsetTop); return false;See the once more updated jsFiddle.But if that’s not what you want either, just say so!