-3

我正在使用 html 5 中提供的占位符属性来获得占位符效果。

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

我还添加了代码来清除提交时的占位符。

$(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("");
            } 
            });
        });
    }
});

但它仍然在提交后给出占位符值。

4

1 回答 1

1

当我将您问题的最后一部分(请建议我在哪里可以获取 excel 格式的所有职业/行业列表)输入谷歌时,我在第 1 页上看到了这个链接。它有一个指向这个电子表格的链接,其中包含确切的内容你正在寻找。我喜欢帮助人们,但说真的,先做一些研究和谷歌搜索。

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

示例数据。

于 2012-08-21T09:15:45.910 回答