js toast库
先看下效果:
js库地址:https://github.com/CodeSeven/toastr
demo:http://codeseven.github.io/toastr/demo.html
如何引用:
<link rel="stylesheet" type="text/css" href="http://codeseven.github.io/toastr/build/toastr.min.css"> <script type="text/javascript" src="http://codeseven.github.io/toastr/build/toastr.min.js" ></script>
主要参数说明:
preventDuplicates: false,/*判断是相同的内容,则只允许出现一个toast,
即,两次toast,如果内容相同,则第二个toast不会显示*/
preventManyTimes: false,/* 同一时刻,只允许出现一个toast **/
实例:
toastr.options = {"timeOut": "3000","preventDuplicates": true,"preventManyTimes": true,"hideDuration": "1"}; var diaryContent=$li.find('a').attr('title'); if(!diaryContent){ diaryContent='暂无内容'; toastr.warning(diaryContent); }else{ toastr.success(diaryContent); }