これは私のデモjsFiddle です
HTML
<canvas id="random"></canvas>
jQuery
function Random() {
var length = 9,
charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
retVal = "";
for (var i = 0, n = charset.length; i < length; ++i) {
retVal += charset.charAt(Math.floor(Math.random() * n));
}
return retVal;
}
var ctx = document.getElementById("random").getContext('2d');
ctx.font = "30px Codystar";
ctx.fillText(Random(), 30, 30);
$("#random").click(function () {
ctx.fillText(Random(), 30, 30);
});
私の質問 1-フォントが最初の起動時に機能せず、2-クリック機能が機能しませんか?