var classname = document.getElementsByClassName('answer');
function myFunction(e){
document.querySelectorAll('.answer').forEach(ans => {
ans.style.background = '#222'
ans.style.color = '#aeaeae'
});
e.target.style.background = '#fff'
e.target.style.color = '#000'
}
for (var i = 0; i < classname.length; i++) {
classname[i].addEventListener('click', myFunction, false);
}
<form class="form-element",
$('#form-element').
<form id="form-element" class="form-element",
$data = $_POST;
if ($data['name']) {
$message = '<html><body>';
$message .= "<table>";
foreach ($data as $key => $value) {
$message .= "<tr>";
$message .= "<td>";
$message .= "<strong> $key: </strong>";
$message .= "</td>";
$message .= "<td style='padding-left:12px;'>";
$message .= " htmlspecialchars(trim($value))";
$message .= "</td>";
$message .= "</tr>";
}
$message .= "</table><br><br>";
$message .= "</body></html>";
require dirname(__DIR__).'/Exception.php';
require dirname(__DIR__).'/PHPmailer.php';
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->setFrom('no-reply@example.com', 'Mail title');
$mail->addAddress('John@mail.ru', 'John Doe');
$mail->Subject = $subject;
// Прикрепление файлов
if (isset($_FILES['photo']) &&
$_FILES['photo']['error'] == UPLOAD_ERR_OK) {
for($i=0;$i<count($_FILES['photo']['tmp_name']);$i++)
{
$uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['photo']['name'][$i]));
$filename =$_FILES['photo']['name'][$i];
if (move_uploaded_file($_FILES['photo']['tmp_name'][$i], $uploadfile)) {
$mail->addAttachment($uploadfile, $filename);
}
}
}
$mail->msgHTML($message);
$r = $mail->send();
if ($r) {
$answer = 'success';
} else {
$answer = 'failure';
}
die($answer);
}
document.getElementById('field').parentNode.classList.add("newclass");
<a href="АДРЕС СТРАНИЦЫ.html" class="open-popup-link">Показать всплывающее окно</a>
$('.open-popup-link').magnificPopup({
type:'ajax',
callbacks: {
parseAjax: function(mfpResponse) {
mfpResponse.data = $(mfpResponse.data).find('#какой-то элемент');
}
}
});
$('.open-popup-link').magnificPopup({
type:'ajax',
callbacks: {
parseAjax: function(mfpResponse) {
mfpResponse.data = $(mfpResponse.data).filter('#какой-то элемент');
}
}
});