use jquery to select the button with the same id as the randomchosencolour code example Example: get element by id in Jquery $("#YourElementId").val();