Javascript Sweet Alert and html link inside text

后端 未结 5 1564
暖寄归人
暖寄归人 2021-01-25 10:46

i have the following SweetAlert Code..



        
5条回答
  •  情话喂你
    2021-01-25 11:39

    As Jeremy Thille found out in his commentary on Oct. 31 '17 at 10:36:

    You do not need to use the option "content" for a simple link in the text. The option "text" can only display pure text, no html. However, the option "html" can display html.

    Not to be confused with the old version SweetAlert 1.X: There you had to set html = true.

    In SeewtAlert2, the html is set directly in the "html" option. Do not use option "text" in this case.

    Works fine in sweetAlert.version = '6.9.1';

    Example of Jeremy Thille:

    $('.patient-details').click(function(e) {
      e.preventDefault();
      var $this = $(this)
      var name = $this.data('name');
      var gender = $this.data('gender');
      var age = $this.data('age');
      var country = $this.data('country');
      var address = $this.data('address');
      var report = $this.data('report');
    
      swal({
      title: name,
      html:
          "Gender: " + gender +"
    " + "Age: " + age +"
    " + "Country: " + country +"
    " + "Address: " + address +"
    " + "Report: " + report +"
    " + "Report " + "and other HTML tags" }); });

    https://codepen.io/jeremythille/pen/wPazMw

提交回复
热议问题