HTML代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>中文正则</title>
    <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
    //这里把下面的javascript代码粘帖上来
</head>
<body>
    <input type="text" name="text">
    <input type="button" value="点我" id="btn">
</body>
</html>

JS代码:

<script type="text/javascript">
$(function(){
            $('#btn').click(function() {
                var val = $('input[name=text]').val();
                if (/[\u4e00-\u9fa5]/g.test(val)) {
                    alert('是中文');
                }else{
                    alert('不是中文');
                }
            });
        })

</script>

js给当前url添加get参数,兼容旧参数

example updateQueryStringParameter("https://www.baidu.com?a=123",'b','hello') //result https://www.baidu.com/?a=123&b...

阅读全文

使用js弹出chrome windows通知提醒

废话少说,直接上代码 function notifyMe(notification_title, body) { if (Notification.permission !== "granted") Notification.re...

阅读全文

dropzone 插件只上传一张图片

<div> <div class="col-md-3"> <div class="form-group"> <label>你的头像</label> ...

阅读全文

2 条评论

欢迎留言