码迷,mamicode.com
首页 > Web开发 > 详细

JS 8*8点阵显示字母

时间:2014-07-29 12:19:37      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   io   for   cti   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        .in
        {
            background-color: Black;
        }
        td
        {
            border: 1px solid #eaeaea;
            width: 2px;
            height: 2px;
        }
    </style>
    <script src="jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        //8*8 数字点阵
        var chars = {};
    //字符库没有做扩展,仅能显示A-F这几个字符,其他字符可自行扩展 chars.A
= [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]; chars.B = [[0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0]]; chars.C = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]; chars.D = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]; chars.E = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]; chars.F = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]; </script> </head> <body> 8*8 点阵<br /> 请输入字母(A~F):<input type="text" id="txtChar" /> <input id="btnGeneral" type="button" value="生成" /> <table id="tableDot" cellpadding="0" cellspacing="0"> <script> for (var i = 0; i < 8; i++) { document.write("<tr>"); for (var j = 0; j < 8; j++) { document.write("<td></td>"); } document.write("</tr>"); } </script> </table> <script type="text/javascript"> $("#btnGeneral").click(function () { var input_char = $("#txtChar").val(); try { var charHex = chars[input_char]; $(".in").removeClass("in"); $("#tableDot tr").each(function (i) { $(this).find("td").each(function (j) { if (charHex[i][j] == 1) { $(this).addClass("in"); } }) }) } catch (e) { } }) </script> </body> </html>

 

JS 8*8点阵显示字母,布布扣,bubuko.com

JS 8*8点阵显示字母

标签:style   blog   http   java   color   io   for   cti   

原文地址:http://www.cnblogs.com/yangml/p/3874786.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!