$(function () {

    if (!placeholderSupport()) {

        $('[placeholder]').focus(function () {

            var input = $(this);
            if (input.val() == input.attr('placeholder')) {
                input.val('');
                input.removeClass('placeholder');
            }

        }).blur(function () {
            var input = $(this);
            if (input.val() == '' || input.val() == input.attr('placeholder')) {
                input.addClass('placeholderSupport');
                input.val(input.attr('placeholder'));
            }
        }).blur();
    }
});
function placeholderSupport() {
    return 'placeholder' in document.createElement('input');
}

posted on 2015-09-14 17:07  邢帅杰  阅读(293)  评论(0编辑  收藏  举报