Refactored js of popDiv.