With jQuery, construct an array that has the values ["A", "B", "C", "D", "E", "F"] by getting the letters stored in the following html elements and pushing them into the array?
<div class="select-container" data-letter="A">
B
<div class="select-wrapper">
<ul>
<li id="select-first">D</li>
<li></li>
<li>E</li>
<li></li>
C
</ul>
</div>
<div>
<span>F</span>
</div>
</div>
Submitted by: Administratorvar letterArray = [];
// A
letterArray.push($('.select-container').data("letter"));
// B
var b = $('.select-container').contents().filter(function() {
return this.nodeType === 3 && this.nodeValue.trim() !== '';
}).text().trim();
letterArray.push(b);
// C
var c = $('.select-wrapper ul').contents().filter(function() {
return this.nodeType === 3 && this.nodeValue.trim() !== '';
}).text().trim();
letterArray.push(c);
// D
letterArray.push($('#select-first').text());
//E
letterArray.push($('.select-wrapper li').eq(2).text());
// F
letterArray.push($('.select-container > div:last-child span').text());
// Console Log the array.
console.log(letterArray);
Submitted by: Administrator
// A
letterArray.push($('.select-container').data("letter"));
// B
var b = $('.select-container').contents().filter(function() {
return this.nodeType === 3 && this.nodeValue.trim() !== '';
}).text().trim();
letterArray.push(b);
// C
var c = $('.select-wrapper ul').contents().filter(function() {
return this.nodeType === 3 && this.nodeValue.trim() !== '';
}).text().trim();
letterArray.push(c);
// D
letterArray.push($('#select-first').text());
//E
letterArray.push($('.select-wrapper li').eq(2).text());
// F
letterArray.push($('.select-container > div:last-child span').text());
// Console Log the array.
console.log(letterArray);
Submitted by: Administrator
Read Online User Interface Expert Job Interview Questions And Answers
Top User Interface Expert Questions
☺ | Explain what is the difference between linking to an image, a website, and an email address? |
☺ | What is something new / something you have found interesting recently? |
☺ | Name some online resources you reference when having CSS issues? |
☺ | Tell me why did you get into coding, programming, etc.? |
Top Graphical User Interface (GUI) Categories
☺ | User Interface Expert Interview Questions. |
☺ | Front End Programmer Interview Questions. |
☺ | Lead Web Designer Interview Questions. |
☺ | Senior Graphics Designer Interview Questions. |
☺ | Web Designer Freelance Interview Questions. |