0

Using a JSfiddle I found online I am displaying a numeric keypad. ATM the keypad appears and disappears as the user clicks the input button.

I would like to remove this feature from the script code, allowing the keypad to be visible at all times, but am unsure which part to remove from the code:

 <script>
    $(document).ready(function () {
        $('#myInput').click(function () {
            $('#n_keypad').fadeToggle('fast');
        });
        $('.done').click(function () {
            $('#n_keypad').hide('fast');
        });
        $('.numero').click(function () {
            if (!isNaN($('#myInput').val())) {
                if (parseInt($('#myInput').val()) == 0) {
                    $('#myInput').val($(this).text());
                } else {
                    $('#myInput').val($('#myInput').val() + $(this).text());
                }
            }
        });
        $('.neg').click(function () {
            if (!isNaN($('#myInput').val()) && $('#myInput').val().length > 0) {
                if (parseInt($('#myInput').val()) > 0) {
                    $('#myInput').val(parseInt($('#myInput').val()) - 1);
                }
            }
        });
        $('.pos').click(function () {
            if (!isNaN($('#myInput').val()) && $('#myInput').val().length > 0) {
                $('#myInput').val(parseInt($('#myInput').val()) + 1);
            }
        });
        $('.del').click(function () {
            $('#myInput').val($('#myInput').val().substring(0, $('#myInput').val().length - 1));
        });
        $('.clear').click(function () {
            $('#myInput').val('');
        });
        $('.zero').click(function () {
            if (!isNaN($('#myInput').val())) {
                if (parseInt($('#myInput').val()) != 0) {
                    $('#myInput').val($('#myInput').val() + $(this).text());
                }
            }
        });
    });
</script>

UPDATE Also, the keypad appears on the left, how can I align it to the right. I dont see any ref to alignment in the code?

4

1 回答 1

2

如果你创建一个小提琴,它会更容易提供帮助。从外观上看,似乎是这些线条

$('#n_keypad').fadeToggle('fast');
});
$('.done').click(function () {
            $('#n_keypad').hide('fast');
});

我相信对齐是使用 CSS 完成的。您必须提供标记或创建小提琴。

于 2013-09-17T10:16:17.647 回答