I'm working on creating a tool that can find the tallest element among a group of elements and then adjust the height of all elements to match the tallest one.
Within this tool, I'm attempting to pass a selector to a JQuery method that is located inside the tool's own method. Unfortunately, I am encountering an issue where my Each statement is not executing and the tool is returning 0 items.
Below is an example of the tool implementation:
var elementHeightAdjuster = {
containerName: '',
childElements: '',
alert: function() {
var divs = $(this.childElements);
console.log(divs);
$.each(divs, function(index, value) {
console.log('working');
});
}
}
elementHeightAdjuster.containerName = '#containers';
elementHeightAdjuster.childElements = 'div';
elementHeightAdjuster.alert();
#one {
background-color: green;
width: 50px;
height: 200px;
}
div {
width: 50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="containers">
<div id="one">d</div>
<div id="two"></div>
<div id="three"></div>
<div id="four"></div>
<div id="five"></div>
</div>