<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>使用jQuery手工触发事件</title>
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <!--<script type="text/javascript" src="js/js6.js"></script>-->
    <link rel="stylesheet" type="text/css" href="css/css6.css">
</head>

<script>
    function inputHandler(e) {
        var chr=String.fromCharCode(e.charCode);
        $("p").append(chr);
    }

    function  spanHandler(e) {
        var chrCode=e.target.innerHTML.charCodeAt(0);
        $("input").trigger({'type':'keypress','charCode':chrCode});
    }

    $(document).ready(function () {
        $("input").keypress(function (e){inputHandler(e)});
        $("span").click(function (e){spanHandler(e)});
    });
</script>

<body>

   <p>Price:</p>
   <input type="text" />
   <span>&#x24;</span>
   <span>&#xa3;</span>
   <span>&#xa5;</span>
   <span>&#x20ac;</span>

</body>
</html>
span{
    border-radius: 5px;
    margin:3px;
    padding:5px;
    background-color: #c0c0c0;
    border:3px ridge;
    display: inline-block;
    cursor: pointer;
}

p{
    border:4px outset blue;
    padding:3px;
    color: white;
    background-color: blue;
    font-size: 30px;
    font-weight: bold;
}