2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
id: bad87fee1348bd9aedf08830
|
|
|
|
title: Add Placeholder Text to a Text Field
|
|
|
|
challengeType: 0
|
|
|
|
videoUrl: 'https://scrimba.com/p/pVMPUv/cKdJDhg'
|
2019-07-31 18:32:23 +00:00
|
|
|
forumTopicId: 16647
|
2021-01-13 02:31:00 +00:00
|
|
|
dashedName: add-placeholder-text-to-a-text-field
|
2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --description--
|
|
|
|
|
|
|
|
Placeholder text is what is displayed in your `input` element before your user has inputted anything.
|
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
You can create placeholder text like so:
|
2020-11-27 18:02:05 +00:00
|
|
|
|
|
|
|
`<input type="text" placeholder="this is placeholder text">`
|
|
|
|
|
|
|
|
**Note:** Remember that `input` elements are self-closing.
|
|
|
|
|
|
|
|
# --instructions--
|
|
|
|
|
|
|
|
Set the `placeholder` value of your text `input` to "cat photo URL".
|
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
|
|
|
You should add a `placeholder` attribute to the existing text `input` element.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert($('input[placeholder]').length > 0);
|
|
|
|
```
|
|
|
|
|
|
|
|
You should set the value of your placeholder attribute to `cat photo URL`.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert(
|
|
|
|
$('input') &&
|
|
|
|
$('input').attr('placeholder') &&
|
|
|
|
$('input')
|
|
|
|
.attr('placeholder')
|
|
|
|
.match(/cat\s+photo\s+URL/gi)
|
|
|
|
);
|
|
|
|
```
|
|
|
|
|
|
|
|
The finished `input` element should not have a closing tag.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert(!code.match(/<input.*\/?>.*<\/input>/gi));
|
2018-09-30 22:01:58 +00:00
|
|
|
```
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
The finished `input` element should have valid syntax.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert($('input[type=text]').length > 0);
|
|
|
|
```
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --seed--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
## --seed-contents--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
```html
|
|
|
|
<h2>CatPhotoApp</h2>
|
|
|
|
<main>
|
|
|
|
<p>Click here to view more <a href="#">cat photos</a>.</p>
|
2018-10-08 00:01:53 +00:00
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
2018-10-08 00:01:53 +00:00
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
<p>Things cats love:</p>
|
|
|
|
<ul>
|
|
|
|
<li>cat nip</li>
|
|
|
|
<li>laser pointers</li>
|
|
|
|
<li>lasagna</li>
|
|
|
|
</ul>
|
|
|
|
<p>Top 3 things cats hate:</p>
|
|
|
|
<ol>
|
|
|
|
<li>flea treatment</li>
|
|
|
|
<li>thunder</li>
|
|
|
|
<li>other cats</li>
|
|
|
|
</ol>
|
|
|
|
<input type="text">
|
|
|
|
</main>
|
|
|
|
```
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --solutions--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2019-04-22 06:07:05 +00:00
|
|
|
```html
|
|
|
|
<h2>CatPhotoApp</h2>
|
|
|
|
<main>
|
|
|
|
<p>Click here to view more <a href="#">cat photos</a>.</p>
|
|
|
|
|
|
|
|
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
|
|
|
|
|
|
|
<p>Things cats love:</p>
|
|
|
|
<ul>
|
|
|
|
<li>cat nip</li>
|
|
|
|
<li>laser pointers</li>
|
|
|
|
<li>lasagna</li>
|
|
|
|
</ul>
|
|
|
|
<p>Top 3 things cats hate:</p>
|
|
|
|
<ol>
|
|
|
|
<li>flea treatment</li>
|
|
|
|
<li>thunder</li>
|
|
|
|
<li>other cats</li>
|
|
|
|
</ol>
|
|
|
|
<input type="text" placeholder="cat photo URL">
|
|
|
|
</main>
|
2018-09-30 22:01:58 +00:00
|
|
|
```
|