carry 2019-10-16 18:23:21 442次浏览 1条评论 0 1 0

http://www.yxpf120.com/feed/43517
这里回复不了代码

简单实现自己优化

<input type="text" id="email" value="" onkeyup="email()" />

<div id="emailBox" style="display:none; border: 1px solid #ff0000;">
    <ul>
        <li onclick="setMail(0)">@gmail.com</li>
        <li onclick="setMail(1)">@qq.com</li>
        <li onclick="setMail(2)">@163.com</li>
    </ul>
</div>

<script>
    function email(){
        var email = document.getElementById('email');

        if( email.value.indexOf('@') != -1 ){
           document.getElementById('emailBox').style.display = 'block'; 
        }
    }

    function setMail( n ){
        var arr = new Array( 'gmail.com', 'qq.com', '163.com' );
        var email = document.getElementById('email');
        email.value = email.value.split("@")[0] +'@'+ arr[n];
    }
</script>
觉得很赞
亿速云
您需要登录后才可以评论。登录 | 立即注册