2017-05-05 68 views
1
var text += '<b>Hii This is Error<b>'; 
swal("Required", text, "error"); 

如何在Bootstrap Sweet alert插件中使用html編碼。如何在甜蜜警報中使用html標記

在上面的代碼我必須寫爲一個錯誤消息!在sweetalert中顯示。但在文本變量中使用html標記時,它需要字符串 ,並且可以在sweetalert中顯示相同的字符串,它不能在html標記中進行轉換。

回答

0

您必須添加html:true用於顯示例如HTML內容,

swal({ 
    title: "Required", 
    text: "<b>Hii This is Error<b>", 
    html: true, // add this if you want to show HTML 
    type: "error" // type can be error/warning/success 
}); 

Sweetalert configuration

+0

謝謝你......爲解決 –

+0

如果作品!然後,將其標記爲答案,以便它可以幫助其他SO用戶。 –

0
swal({ 
title: "Required", 
text: "<b>Please fill the required fields</b>", 
html: true, 
type: "error" 
}); 
相關問題