var putAnXBtn; {
document.getElementById("putAnXButton");
// get a reference to the box
var theBox = document.getElementById("putAnX");
// now get the width and height of the box - see the clientWidth and clientHeight documentation at http://docs.webplatform.org/wiki/dom/HTMLElement
var resultY = element.clientHeight;
element.clientHeight = value;
var height = theBox.clientHeight;
var resultX = element.clientWidth;
element.clientWidth = value;
var width = theBox.clientWidth;
//function onclick(e);{
// var resultY= document.getElementById("putAnX").innerHTML = Math.random();
//xPosition.innerHTML = Math.floor((Math.random() * 100) + 0);
// }
// * Now, here's where you do your magic. The xPosition and yPosition should not be set to zero.
// function onclick(e); {
// var resultX = document.getElementById("putAnX").innerHTML = Math.random();
// yPosition.innerHTML = Math.floor((Math.random() * 100) + 0);
// }
// * Use the Math.random() function to get a number between
// * 0 and 1, then use some math to convert that to a number between 0 and the width. This is your x position.
// *
// * Do the same thing to generate a number between 0 and the height: this is your y position.
// * */
//function onclick(e) {
var yPosition = document.getElementById("putAnX").innerHTML = Math.random();
xPosition.innerHTML = Math.floor((Math.random() * 100) + 0);// should generate a value between 0 and the height
var xPosition = document.getElementById("putAnX").innerHTML = Math.random();
yPosition.innerHTML = Math.floor((Math.random() * 100) + 0); //should generate a value between 0 and the width
//now we'll get the HTML element where the X goes, fill in the X and set the position of the element.
var...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.