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

他的小前端 (1)—— 移动端特殊效果-网页小键盘

时间:2016-02-16 19:05:36      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

移动端的CLICK会延迟,这个效果没看出来延迟,为什么?

页面:

<div id="container" style="width: 200px">
        <p id="write" ></p>
        <ul id="keyboard">
            <li>1</li>
            <li>2</li>
            <li class="delete">delete</li>
        </ul>
    </div>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jianpan.js"></script>

JS:

$(function(){
    var $write = $(‘#write‘);
    $(‘#keyboard li‘).click(function(){
        var $this = $(this),
            character = $this.html(); // If it‘s a lowercase letter, nothing happens to this variable
        
        
        // Delete
        if ($this.hasClass(‘delete‘)) {
            var html = $write.html();
            $write.html(html.substr(0, html.length - 1));
            return false;
        }
        
        // Special characters
        if ($this.hasClass(‘return‘)) character = "\n";
        
        
        // Add the character
        $write.html($write.html() + character);
    });
    
});

他的小前端 (1)—— 移动端特殊效果-网页小键盘

标签:

原文地址:http://www.cnblogs.com/chen-nye/p/5193369.html

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