1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
If this is the markup, what value is returned by the getAttribute() method? | <img src = "pic1.jpg"> | "pic1.jpg" | •pic1\.jpg• |
If you use getAttribute() and there is no such attribute, the value returned is either "" or ____. | null | null | |
The targeted element has been assigned to the variable el. Code the rest of the statement to find the value of the attribute named "target". | let valTarget = ______________________________; | el.getAttribute("target"); | el\.getAttribute\(•target•\); |
Code the rest of the statement to find the value of the src attribute of the only image on the page. | let valSrc = ____________________________; | document.querySelector("img").getAttribute("src"); | document\.querySelector\(•img•\)\.getAttribute\(•src•\); |
The targeted element has been assigned to the variable el. Find the value of an attribute of the element and assign the value to a variable. Make up the attribute name and the variable name. | let valAttribute = el.getAttribute("href"); | let[a-z_$][a-zA-Z0-9_$]*=el\.getAttribute\(•.*•\); | |
In a single statement, find the value of an element's align attribute and assign it to a variable. Target the element by id. Make up the variable name and the id. | let valAttribute = document.querySelector("#div-3").getAttribute("align"); | let[a-z_$][a-zA-Z0-9_$]*=document\.querySelector\(•#.*•\)\.getAttribute\(•align•\); | |
An element has been assigned to the variable el. Check whether a particular attribute on el exists and assign the result to a variable. Make up the attribute and the variable name. | let itExists = el.hasAttribute("title"); | let[a-z_$][a-zA-Z0-9_$]*=el\.hasAttribute\(•.*•\); | |
An element has been assigned to the variable el. Code an if statement. If a src attribute exists on the element, assign it the name of a jpg image. Make up the attribute value. | if (el.hasAttribute("src")) { el.setAttribute("src", "images/loris.jpg"); } |
if\(el\.hasAttribute\(•src•\)\){[\r\n]el\.setAttribute\(•src•,•.*\.jpg•\);[\r\n]} | |
|
|||
|