Autor Zpráva
juraj
Profil
Zdravím
zdrojový kód pre color picker som ztiahol z tejto stránky tu
Ako mám prepojiť funkciu getselect(), ak kliknem na ikonku colopicker, aby mi zostal označený text na zmenu farby
v jazyku javascript?
dakujem
 <link href="mcColorPicker/mcColorPicker.css" rel="stylesheet" type="text/css" />
<script src="mcColorPicker/mcColorPicker.js" type="text/javascript"></script>
<script type="text/javascript">
 function OnColorChanged(selectedColor, colorPickerIndex) {
        var divA = document.getElementById("divA");
          divA.style.color = selectedColor;
     
   }

    function getselect(){
        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);
    
    }
        
</script>
  <span id="divA" >&nbsp;Mr.gggggggggggggggg</span>

<input type="text" class="color" />

<br>

<div   contenteditable="true">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has bee
n the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<br>
<input type="button" onclick="getselect();" value="farba pozadia"/>

Vaše odpověď


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0