dongshai2022 2012-08-21 09:11 采纳率: 100%
浏览 32

html明确占位符提交[关闭]

I am using placeholder attribute provided in html 5 to get placeholder effect.

<input id="search" class="hasPlaceholder" type="text" placeholder="Personal Trainer" 
value="" name="search">

also I have added code to clear the placeolder on submit.

$(function() {
    if(!$.support.placeholder) { 
        var active = document.activeElement;
        $(':text').focus(function () {
            if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
                $(this).val('').removeClass('hasPlaceholder');
            }
        }).blur(function () {
            if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
                $(this).val($(this).attr('placeholder'));
                $(this).addClass('hasPlaceholder');
            }
        });
        $(':text').blur();
        $(active).focus();
        $('form').submit(function () {
            $(this).find('.hasPlaceholder').each(function() {

                var input = $(this);
                input.removeClass('hasPlaceholder');

                if (input.val() == input.attr('placeholder')) {
                input.removeAttr('placeholder');
                input.val("");
            } 
            });
        });
    }
});

but still it gives placeholder value after submit.

  • 写回答

1条回答 默认 最新

  • duancenxie2233 2012-08-21 09:15
    关注

    When I entered the last part of your question (Please suggest where i can get list of all Occupation/Industry in excel format) into google, I came across this link on page 1. It has a link to this spreadsheet which contains the exact thing you are looking for. I like helping folks, but seriously, do a little research and googling first.

    11-0000             Management Occupations
        11-1000         Top Executives
            11-1010     Chief Executives
                11-1011 Chief Executives
            11-1020     General and Operations Managers
                11-1021 General and Operations Managers
            11-1030     Legislators
                11-1031 Legislators
    

    Example Data.

    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助