我希望在点击这些链接但没有任何反应时弹出toastr的通知
编辑:这是完整代码http://jsfiddle.net/XaVcR/的jsfiddle我不确定我是否正确包含toastr尽管 成功 的.js
toastr.options.closeButton = true;
toastr.options.positionClass = "toast-bottom-left";
$(document).ready(function() {
$('#success').click(notification('success', 'this was a success!'));
});
function notification( type, message ) {
if( type == 'success' ) {
toastr.success(message,'<i>Success</i>');
} else if( type == 'error' ) {
toastr.error(message,'Error');
} else if( type == 'warning' ) {
toastr.warning(message,'Warning');
} else {
toastr.info(message,'Information');
}
}
答案 0 :(得分:2)
从问题:
$('#success').click(notification('success', 'this was a success!'));
这应该是:
$('#success').click(function() {
notification('success', 'this was a success!');
});
你的JSFiddle有:
$('#success').click(function() {
notification('success', 'this was a success!'));
});
,中间行末尾的))
是语法错误。