Home > Enterprise >  In js, how to set button caption with css characters
In js, how to set button caption with css characters

Time:02-17

I want to create dynamically a button with css symbol as caption.
I want to put a small arrow.
I try this, without success:

let btnDel = document.createElement("input");
btnDel.type = "button";
btnDel.value = "⇧";

A nudge ?

Best regards

CodePudding user response:

Since it's a JavaScript string, you use a JavaScript Unicode escape sequence rather than an HTML character entity:

btnDel.value = "\u21E7";

let btnDel = document.createElement("input");
btnDel.type = "button";
btnDel.value = "\u21E7";
document.body.appendChild(btnDel);

("del" seems like "delete," though. I wouldn't expect an up-arrow to delete anything.)

  • Related