修改HTML <a> Tag without href attribute Inside a Contenteditable Div

时间:2018-04-28 00:43:24

标签: html css html5 dom

I found when editing a <a> tag, the behavior is different when it has attribute href or not.

  1. Adding character after <a> tag with href (the cursor was inside the <a> node), the added char will not be inside the <a> tag

    <a href="fakelink">tes</a>
    

    type 't' it will become

    <a href="fakelink">tes</a>"t"
    
  2. Adding character after tag without href (the cursor was inside the node), the added char will be inside the tag

    <a>tes</a>
    

    type 't' it will become

    <a>test</a>
    

why is this?

Is it possible to make a span node behave like first case, I mean when you add character after that span node (the cursor was inside the span node), the new char is outside the span node?

0 个答案:

没有答案
相关问题