Insertion Inside Flashcards

1
Q

Append element to single target

target.append(element);

A

target.appendChild(element);

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

Append element to a set of targets

targets.append(element);

A

ES6

for (var target of targets) target.appendChild(element.cloneNode(true)); element.remove();

ES5

targets.forEach(function(target) { target.appendChild(element.cloneNode(true)); }); element.remove();

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

$(parent).prepend(el);

A

parent.insertBefore(el, parent.firstChild);

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

Get element html

var html = element.html();

A

var html = element.innerHTML;

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

Set element html

element.html(‘

foo

’);

A

element.innerHTML = ‘

foo

’;

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

Set html to a set of elements

elements.html(‘

foo

’);

A

ES6

elements.forEach(x => x.innerHTML = ‘

foo

’);

ES5

elements. forEach(function(element) {
element. innerHTML = ‘

foo

’;

});

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

Get element text

var text = element.text();

A

var text = element.textContent;

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

Get element text from a set of elements

vvar text = elements.text();

A

ES6

var text = elements.map(x => x.textContent).join(‘’);

ES5

var text = elements.map(function(element) {

return element.textContent;

}).join(‘’);

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

Set element text

element.text(‘foo’);

A

element.textContent = ‘foo’;

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

Set text to set of elements

elements.text(‘foo’);

A

ES6

elements.forEach(x => x.textContent = ‘foo’);

ES5

elements.forEach(function(element) { element.textContent = ‘foo’;

});

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