web前端开发摄影

价值10亿的AI代码

2019-12-11  本文已影响0人  爱学习的新一

滑稽.png

<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

</head>
<body>
<div class="container">
    <div class="row">
        <div class="jumbotron">
            <h1>价值十亿的AI代码</h1>
            <input type="text" placeholder="输入对话" id="text" class="col-lg-12" style="display: block;height: 50px;font-size: 20px;margin: 30px 0" />
            <input type="button" value="输入" id="btn" class="btn btn-danger" />
        </div>

    </div>
    <div class="panel panel-default row">
        <div class="panel-body">
            对话内容:
        </div>
    </div>

</div>


<script>

    var txt = document.getElementById('text')
    var btn = document.getElementById('btn')
    var msgbox = document.querySelector('.panel-body')
    btn.addEventListener('click',() => {


        let myself = document.createElement('p')
        myself.innerHTML = '我:' + this.txt.value
        msgbox.appendChild(myself)


        let child = document.createElement('p')
        child.innerHTML =  this.txt.value.replace(/你/g,'我').replace(/吗/g,'').replace(/\?/g,'!').replace(/?/g,'!')
        msgbox.appendChild(child)


        this.txt.value = ''

    })

    txt.addEventListener('keydown',(e)=>{
        if (e.keyCode==13) {
            this.btn.click()
        }
    })
</script>
</body>
</html>


上一篇下一篇

猜你喜欢

热点阅读