I am trying to write a js for any simple html side. The js should pick all img or p elements for example and swap the position of 2 random elements of the same type by clicking a button.
let max = document.getElementsByTagName("img").length;
let min = 0;
let x1 = Math.round((Math.random() * (max - min)) + min);
let x2 = Math.round((Math.random() * (max - min)) + min);
let tmp1 = document.getElementsByTagName("img")[x1];
let tmp2 = document.getElementsByTagName("img")[x2];
thats my first steps but i dont know how to go on. hope someone can help