你能帮我看看下面的代码吗?
弹出窗口打开时,我希望身体模糊或灰色透明且不透明度较低。
$(function() {
// contact form animations
$('#contact').click(function() {
$('#contactForm').fadeToggle();
})
$(document).mouseup(function (e) {
var container = $("#contactForm");
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.fadeOut();
}
});
});
我试着添加
$("body").css("opacity","0.25");
只改变不透明度,但形式也改变了......
HTML 是:
<div id="contact">Contact</div>
<div id="contactForm">
<h1>Keep in touch!</h1>
<small>I'll get back to you as quickly as possible</small>
<form action="#">
<input placeholder="Name" type="text" required />
<input placeholder="Email" type="email" required />
<input placeholder="Subject" type="text" required />
<textarea placeholder="Comment"></textarea>
<input class="formBtn" type="submit" />
<input class="formBtn" type="reset" />
</form>
</div>