Javascript Sweet Alert and html link inside text

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

i have the following SweetAlert Code..



        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-25 11:39

    If you are not still able to find a solution, I tried recreating the modal https://codepen.io/AJALACOMFORT/pen/zPGqNe?editors=0010

    window.onload= function(){
      var that = $(".patient-details")
      var name = $(that).attr('data-name');
    var gender = $(that).attr('data-gender');
    var age = $(that).attr('data-age');
    var country = $(that).attr('data-country');
    var address = $(that).attr('data-address');
    var report = $(that).attr('data-report');
    
       //creates h2
        var h2 = document.createElement("h2")
            //adds text
            h2.innerHTML = name
      //creates p tag 
        var p = document.createElement("p")
             p.innerHTML =  "Gender: " + gender +"\n" + "Age: " + age +"\n" + "Country: " + country +"\n"  + "Address: " + address +"\n" + "Report: " + report
      //creates button
      var button = document.createElement("button")
        //adds the onclick function
          button.setAttribute("onclick", "callbutton(event)")
      button.innerHTML ="ok"
      button.className += "confirm"
      var link = document.createElement("a")
          link.setAttribute("href", report)
          link.innerHTML ="Link"
          link.className += "report-link"
      //appends all the elements into the mymodal div
      var modal = document.getElementById("modal-inner")
            modal.appendChild(h2)
              modal.appendChild(p)
              modal.appendChild(link)
            modal.appendChild(button)
    
    
    }
     //listens to click event of the checkbox
      function callbutton(){
          document.getElementById("checkboxabove").checked = false;
      }
    

    Hopefully it helps. (Note I did not use the same transition effect like in sweet alert, so adjust as you please)

提交回复
热议问题