javascript - How to update href ID using AJAX -
i have following link in code:
<li onclick="loadnewpage('test')"><a href="#">link</a></li>
when user click link, use xmlhttprequest update content in div on webpage.
but @ same time, when user click link, want add id, state of button can changed using css. (note "id" being added link)
<li onclick="loadnewpage('test')"><a href="#" id="current">link</a></li>
at same time, if these other link on page id "current" want remove id.
is possible? how this?
it practice every element want handle in html has own, fixed id.
i suggest put id when creating page. if want change something, may change class of element instead of id.
initial:
<li onclick="loadnewpage('test')"><a href="#" id="section_1">link</a></li>
after clicking:
<li onclick="loadnewpage('test')"><a href="#" id="section_1" class="selected">link</a></li>
jquery (amongst other libraries) provide useful methods retrieve elements of given class, in order change them.
Comments
Post a Comment