HTML:
<script src="../../Scripts/notificator.js" type="text/javascript"></script>
<span id="popUpMessageBoard"/>
<button onclick="success('message', 'popUpMessageBoard')">Add</button>
<button onclick="remove('popUpMessageBoard')">Remove</button>
javascript:
success = function (messageToApply, elementIdToApplyMessages) {
$('#' + elementIdToApplyMessages).append('<strong class="notification" style="color:blue">' + messageToApply + ' </strong>');
};
remove = function (elementId) {
$('#' + elementId).remove('.notification');
}
将Add button
元素附加到popUpMessageBoard span element
. 单击删除按钮时,我希望.notification class
从父 span 元素中删除所有带有 的元素。我错过了什么?