This use case is more of a general JavaScript task. There are quite a few online resources that talk about how to use JavaScript to dynamically modify DIV tags. For example:
http://stackoverflow.com/questions/2098403/rewriting-html-code-using-javascript
http://www.pixel2life.com/forums/index.php?/topic/40498-rewriting-the-contents-of-a-div-tag/
http://stackoverflow.com/questions/918792/use-jquery-to-change-an-html-tag
http://stackoverflow.com/questions/1570905/use-jquery-to-set-value-of-div-tag
The other links you referenced are about changing links within AEM. The one that Shekhar referenced talks about how to use the JCR API to get JCR content and modify nodes/props. But you need to simply modify DIV tags in content located in AEM.