I have a div that contains links(dynamic) and want when users clicked on a link to delete the path from the href attrybute and to add another.
For example: I want to convert this:
<div id="example">
<a href="/some path/page_id=8">Link1</a>
<a href="/some path/page_id=8">Link2</a>
<a href="/some path/page_id=8">Link3</a>
......
</div>
to :
<div id="example">
<a href="/some path/ANOTHER_PATH">Link1</a>
<a href="/some path/ANOTHER_PATH">Link2</a>
<a href="/some path/ANOTHER_PATH">Link3</a>
......
</div>
I’m a nooby in php and javascript, so any help would be greatly appreciated.
Thanks
This should work for you (assuming you have jQuery)
See it working here on jsFiddle
EDIT
If you need a native JavaScript version, here you go
See it working here on jsFiddle