DOM Attributes Flashcards

1
Q

attribute.name

var x = document.getElementsByTagName(“BUTTON”)[0].attributes[0].name;

A

Returns the name of an attribute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

attribute.value = value

var x = document.getElementsByTagName("IMG")[0];
x.getAttributeNode("src").value = "pic_bulbon.gif";
A

Sets or returns the value of the attribute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

attribute.specified

var x = document.getElementById(“demo”).attributes[0].specified;

A

Returns true if the attribute has been specified, otherwise it returns false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

namednodemap.getNamedItem(nodename)

var btn = document.getElementsByTagName("BUTTON")[0];
btn.attributes.getNamedItem("onclick").value;
A

Returns a specified attribute node from a NamedNodeMap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

namednodemap.item(index)

var x = document.getElementsByTagName(“BUTTON”)[0].attributes.item(0).nodeName;

A

Returns the attribute node at a specified index in a NamedNodeMap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

namednodemap.length

A

Returns the number of attribute nodes in a NamedNodeMap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

namednodemap.removeNamedItem(nodename)

var btn = document.getElementsByTagName("INPUT")[0]; 
btn.attributes.removeNamedItem("type");
A

Removes a specified attribute node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

namednodemap.setNamedItem(node)

var h = document.getElementsByTagName("H1")[0];
var typ = document.createAttribute("class");
typ.value = "democlass";
h.attributes.setNamedItem(typ);;
A

Sets the specified attribute node (by name)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly