I am trying to implement a close button for my popup DIVs. Each one has a unique ID and I want to hide them by setting the CSS 'display' property to 'none' when closed.
However, the following example is not functioning as expected. I am puzzled as to why...
Javascript
function CloseDiv(element) {
var id = $(element).closest('div').attr('id')
alert(id); // It correctly returns the ID
$("#" + id).css("display", "none");
}
HTML
<span id='close' onclick='CloseDiv(this)'>x</span>