freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-html-and-html5/add-placeholder-text-to-a-t...

1.0 KiB

id title challengeType videoUrl forumTopicId
bad87fee1348bd9aedf08830 给输入框添加占位符文本 0 https://scrimba.com/p/pVMPUv/cKdJDhg 16647

--description--

Placeholder占位符是用户在input输入框中输入任何东西前的预定义文本。

你可以像这样创建一个占位符:

<input type="text" placeholder="this is placeholder text">

--instructions--

input输入框的placeholder占位符文本设置为 “猫咪图片地址”。

--hints--

给现有的input输入框添加一个placeholder属性。

assert($('input[placeholder]').length > 0);

设置placeholder属性的值为 ”猫咪图片地址“。

assert(
  $('input') &&
    $('input').attr('placeholder') &&
    $('input')
      .attr('placeholder')
      .match(/猫咪图片地址/gi)
);

完整的input元素应有一个结束标签

assert(!code.match(/<input.*\/?>.*<\/input>/gi));

input输入框的语法必须正确。

assert($('input[type=text]').length > 0);

--solutions--