Click Tracker test

attempt at a script to record clicks with a timestamp

by SebastianPataneMasuelli

HTML

<div>
    <select>
        <option value="0">2</option>
        <option value="1">1</option>
    </select>
    <br />
    <input type="text" value="sample text"/>
    <button>
        test button
    </button>
</div>

<span></span>

CSS

body {width: 100%; height: 400px; position: relative; border: 1px solid gray}
em {
    position: absolute;
    border-radius: 5px;
    border: 5px solid red;
    height: 0;
    width: 0;
}

JavaScript

var marker = '<em class="marker"></em>';

//start timer, or record time from the system

//detect click location and element
$('body').click(function(e){
     $('span').html(e.pageX +', '+ e.pageY);
     $('body').append(marker);
     $('.marker').last().css('left', e.pageX -16).css('top', e.pageY -16);
     
    //get time 
    var now = new Date();
var pretty = [
 /* now.getFullYear(),
  '-',
  now.getMonth() + 1,
  '-',
  now.getDate(),
  ' ',
  now.getHours(),
  ':',
  now.getMinutes(),
  ':',*/
  now.getSeconds(),
  ':',
  now.getMilliseconds()
].join('');

    $('body').prepend(pretty + '<br />');
    
});

$('button').click(function(){
    $('body').append('bb');
});