Commit 7ee98d08 authored by Harry Glatz's avatar Harry Glatz

Merge branch '1-error-if-no-element-t3js-banners' into 'master'

Resolve "Error if no "element" // ".t3js-banners""

Closes #1

See merge request !2
parents 2f5a04ad 7efa1ddb
......@@ -7,8 +7,10 @@ var randombanners = {} || window.randombanners;
*/
randombanners.shuffle = function (element) {
$element = document.querySelector(element);
for (var i = $element.children.length; i >= 0; i--) {
$element.appendChild($element.children[Math.random() * i | 0]);
if ($($element).length > 0) {
for (var i = $element.children.length; i >= 0; i--) {
$element.appendChild($element.children[Math.random() * i | 0]);
}
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment