Skip to content

Commit

Permalink
27. DOM Scripting: Play/Pause Part 2 – Assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Colleen committed Sep 29, 2015
1 parent 116f17f commit ca5ad59
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions scripts/album.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,29 @@ var setCurrentAlbum = function(album) {
}
};

var child = document.getElementsByClassName('album-view-title')[0];
var noParent = document.querySelector('html');

var findParentByClassName = function(element, targetClass) {
var currentParent = element.parentElement;
while (currentParent.className != targetClass) {
currentParent = currentParent.parentElement;

if (currentParent) {
while (currentParent.className && currentParent.className != targetClass) {
currentParent = currentParent.parentElement;
}

if (currentParent.className == targetClass) {
return currentParent;
} else {
alert("No parent with that class name found.");
}
} else {
alert("No parent found.");
}
return currentParent;
};

findParentByClassName(child, 'album-view');

var getSongItem = function(element) {
switch (element.className) {
case 'album-song-button':
Expand Down

0 comments on commit ca5ad59

Please sign in to comment.