Ok I give up and would really appreciate it if you guys could cast their eye over this for me? I'll try not to ramble.
Goal is to have a 'rendered-view' showing 'rendered' HTML (clickable links) and 'source-view' showing the actual HTML of whatever is in the rendered view. When a link is clicked it is made not a link any more and simply becomes the anchor text. The source then needs to update to reflect this. That's the idea anyway.
The rendered links have an id, href, title and class attributes plus a <strong>
tag. I don't want the id, title or class to show in the source view.
I have it so upon clicking, the 'href' and <strong>
are removed, then I remove the class and title from ALL links. I need to keep the id in source view so the undo function I've created still works.
So, the problem is basically:
<div>
with id of 'rendered-view' contains the rendered version of:
<a id="link1">blah blah</a>
<a id="link2" href="http://www.somesite.com"><strong>Visit this site</strong></a>
i.e:
blah blah
Source view should result in:
blah blah
<a href="http://www.somesite.com"><strong>Visit this site</strong></a>
I know a regular expression will be needed which is where I fail badly at the moment. I'm a PHP guy really and brand new to jQuery so would appreciate the help.