简体   繁体   中英

How can i insert a white dot when pressing keycode 9 in javascript?

I'm trying to insert a white dot and some spaces when I press the keycode 9(TAB), but i can't get it to work. When I insert the dot it never appears in white, it's allways black.

Can someone help me?

The code that im using is this one:

function WebHtmlEditor1_KeyDown(oEditor, keyCode, oEvent) {

      if (keyCode == 9) {
         var point = document.createElement("SPAN");
         var object = document.createElement("SPAN");

         var style = point.style;
         style.fontColor = "White";
         console.log(style);

         point.innerHTML = '<span style:"color="#ffffff"">TESTE</span>';
         object.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

         //console.log(object);
         iged_insText(point.innerText, false);
         iged_insText(object.innerText, false);
         oEvent.cancel = true;
     }
}

You have many typos.

point.innerHTML = '<span style:"color="#ffffff"">TESTE</span>'; 
  1. A colon ( : ) after the style attribute when you should have an equals ( = ).
  2. An equals ( = ) after the color declaration when you should have a colon( : ).
  3. Double-quotes around the CSS declaration.

Replace that line with this one:

point.innerHTML = '<span style="color:#ffffff">TESTE</span>';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM