How would I access(throught JavaScript) an anchor element without it having any attributes except “href”?
Example: <a href="http://www.example.com/forum/addPost/id=5"
Okay, now the “id” in the URL changes, so can I use like substr(), or something else to “cut” the href attribute value in half. So it would now be href="http://www.example.com/forum/addPost/id=".
Now what if there were multiple anchor tags on the page, how would I ‘access’ the anchor tag with the specific href?
If you are not opposed to using jQuery, this is pretty straightforward. To access a hyperlink if you have the ID value to search with:
The $anchor object would be a reference to the DOM element whose href ends with the ID that you specify.