jQuery, 文本框获得焦点后, placeholder提示文字消失

文本框获得焦点后, 提示文字消失, 基于jQuery, 兼容性: html5

//所有文本框获得焦点后, 提示文字消失
    $('body').on('focus', 'input[placeholder]', function () {
        var valueBak = $(this).attr('xplaceholder');
        if (!valueBak) {
            $(this).attr('xplaceholder', $(this).attr('placeholder'));
        }
        $(this).attr('placeholder', '');
    }).on('blur', 'input[placeholder]', function () {
        $(this).attr('placeholder', $(this).attr('xplaceholder'));
    });

 

posted @ 2017-06-27 09:41  sanshizi  阅读(1712)  评论(0编辑  收藏  举报