Factored out function to get space on board from dom element.