Jquery消息提示插件toastr

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<meta http-equiv="X-UA-Compatible" content="ie=edge" />

<title>Document</title>

<link rel="stylesheet" href="build/toastr.min.css" />

</head>

<body>

<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>

<script src="build/toastr.min.js"></script>

<script>

$(function() {

success_prompt_alert()

})

function success_prompt_alert(content) {

toastr.options = {

closeButton: false,

debug: false,

progressBar: false,

positionClass: 'toast-top-center',

onclick: null,

showDuration: '300',

hideDuration: '1000',

// timeOut: "1000",

extendedTimeOut: '1000',

showEasing: 'swing',

hideEasing: 'linear',

showMethod: 'fadeIn',

hideMethod: 'fadeOut'

}

if (content == null) {

content = ''

}

var len = content.length

if (len <= 10 && len > 0) {

toastr.options.timeOut = '1800'

} else if (len <= 20) {

toastr.options.timeOut = '2800'

} else if (len <= 30) {

toastr.options.timeOut = '3800'

} else if (len > 30) {

toastr.options.timeOut = '4800'

}

toastr.success(content)

}

</script>

</body>

</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章