0

I currently have a working drop-down list that allows me to change the font-size of the words inside my contenteditable div. However, it affects the entire contenteditable, instead of just the selected text.

        <select onchange="$('#editor1').css('font-size', event.target.value + 'px')">
        <option value="10">10</option>
        <option value="12">12</option>
        <option value="14">14</option>
        <option value="16">16</option>
        <option value="20">20</option>
        <option value="24">24</option>
        <option value="28">28</option>
        <option value="32">32</option>
        <option value="40">40</option>
        </select>   
cosmo
  • 751
  • 2
  • 14
  • 42
  • I've tried the code there, it's still not working. Here's the javascript I used: function select(){ { var selection= window.getSelection().getRangeAt(0); var selectedText = selection.extractContents(); var span= document.createElement("span"); span.style.backgroundColor = "yellow"; span.appendChild(selectedText); selection.insertNode(span); } This is my button: – cosmo Jul 19 '16 at 05:38
  • Please don't post code in the comments, it's really messy. What do you mean it's not working – Andrew Li Jul 19 '16 at 05:39
  • Fixed it, sorry. Thanks for the link! – cosmo Jul 19 '16 at 05:44
  • No problem, in the future, it's better to search up these questions before asking – Andrew Li Jul 19 '16 at 05:44

0 Answers0