0

ボタンをクリックすると、いくつかのメッセージが表示されます.IEではうまく動作しますが、ffまたはchromeでは動作しません。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title> New Document </title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
    <script>
        $(function(){
            $("#test").bind("input propertychange",function(){
                alert("abc");
            });
        });
        function ff() 
                { 
                document.getElementById('test').value=Math.random(); 

    </script>
</head>
<body>
    <input id="test"></input>
    <input id='btn' value="tt" type="button" onclick="ff()" /> 
</body>
</html>
4

2 に答える 2

0

コードにいくつかのエラーがあります:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title> New Document </title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
    <script>
    $(function () {
        $('#btn').on('click', function () {
            $('#test').val(Math.random());
            $('#test').trigger('change');
        }); //missing ending }
        $('#test').bind("change paste keyup", function () { // change to a proper listener 
            alert("abc");
        });
    });
    </script>
</head>
<body>
    <input id="test" type="text" value="" />
    <!--             ^ Specify a "type" -->    
    <input id='btn' value="tt" type="button" /> 
</body>
</html>
于 2013-06-09T04:40:36.113 に答える