jquery将html转为word,将html转换为纯文本jquery .ajax

请找到下面的jQuery代码。完美发送电子邮件,但我在电子邮件中看到大量代码(HTML)。我想将#right的html()输出转换为text()。我怎样才能做到这一点?将html转换为纯文本jquery .ajax

$(document).ready(function() {

$('.confirm_button').click(function() {

var student_name = $.trim($('#student_name').val());

var student_contact = $.trim($('#student_contact').val());

var student_email = $.trim($('#student_email').val());

var right = $('#right').html();

if (student_name.length < 3 || student_contact.length < 8 || student_email.length < 4)

{

$('#sendfail').attr('title', 'Sending Failed!').text('Please Enter valid information. All fields are required').dialog({

buttons: {

'Ok': function() {

$(this).dialog('close');

$location.reload(true);

}

},

closeOnEscape: true,

draggable: false,

resizable: false,

modal: true

});

}

else

{

var objAjaxRequestData = {

'student_name': student_name,

'student_contact': student_contact,

'student_email': student_email,

'right': right

};

$.ajax({

type: 'POST',

url: 'send-select-university.php',

data: objAjaxRequestData,

success: function() {

$('#sendsuccess')

.attr('title', 'Message sent successfully')

.text('Your message has been sent. We will be in touch soon')

.dialog({

buttons: {

'Ok': function() {

$(this).dialog('close');

window.location = "http://www.ankooverseas.com";

}

},

closeOnEscape: true,

draggable: false,

resizable: false,

modal: true

});

},

error: function() {

alert('Oops request sending failed. Please check your internet connection and try again');

}

});

}

});

});

+0

尝试此解析Html - https://api.jquery.com/jquery.parsehtml/ –

+0

如果您将电子邮件设置为以HTML格式发送,它将使用HTML正确呈现邮件,而不是向您显示源代码。在PHPMailer中,你只需要调用'$ mail-> isHTML();' –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值