I know how to set an <a />
tag with the href
attribute in a contenteditable
like this:
execCommand("CreateLink", false, "#jumpmark");
which will result in
<a href="#jumpmark">selection</a>
However I cannot figure out how to set an anchor name
instead of the href
.
This is my desired result:
<a name="jumpmark">selection</a>
Can anyone help me?
Side notes: I am using jQuery and Rangy as libraries, however I would prefer a solution that works directly with execCommand.
Update: Here's a jsfiddle: http://jsfiddle.net/fjYHr/ Select some text and click the button. All I want is that with the button click a link is inserted with a name attribute set instead of the href.