需要在JS文件中包含HTML代码

时间:2019-03-28 09:27:39

标签: javascript jquery html

我需要从jQuery文件中调用HTML标记。我尝试了很多次,并且尝试了很多方法。谁能建议我如何在JS代码中实现此HTML标签?

如果我单击按钮,则需要检查if条件。如果它进入else,则需要弹出一个小对话框。

$("#validate").on('click', function() {
  var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
  var emailID = $('#email').val();
  var bool = emailReg.test(emailID);
  console.log("the bool is", bool)
  if (bool == false || emailID == null || emailID == "") {
    alert("invalid email")
  } else {
    window.location.href = '"#small-dialog';
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="small-dialog" class="dialog dialog-sm zoom-anim-dialog mfp-hide">
  <h1>Confirm Again</h1>
  <p>Still you need to unSubscribe your email from enlisted list. Please click "Yes" below or if you don't want to unSubscribe , then please click "No" </p>
  <div class="form-row">
    <div class="form-group col">
      <input type="button" class="btn" id="submit" style="background-color: darkred; color: white" value="Yes">
      <button onClick="parent.location='Confirm_Unsubscribe.html'" class="btn  " style="background-color: darkred; color: white">No</button>
    </div>
  </div>
</div>

0 个答案:

没有答案