1
我有一个表单页面,在用户填写表单并点击提交按钮后,应该显示成功警报(Boostrap)。在Node中使用POST操作后在EJS中更改元素样式 - Express
<form class="well form-horizontal" action="/contact" method="post" id="contact_form">
... (input fields here)
<div class="alert alert-success" role="alert" id="success_message"> Success
<i class="glyphicon glyphicon-thumbs-up" ></i> Thanks for contacting us, we will get back to you shortly.
</div>
<div class="form-group">
<label class="col-md-3 control-label"></label>
<div class="col-md-6">
<button type="submit" class="btn btn-warning" > Submit <span class="glyphicon glyphicon-send"></span></button>
</div>
</div>
默认情况下,在我的CSS:
#success_message { display: none; }
如何更改显示属性不none
(块,内联,内联块),以便出现成功警报消息,后Node-Express中的POST操作?
var router = express.Router();
router.post('/', function(req, res, next) {
const data = {
fname: req.body.name,
lname: req.body.lname,
...
comment: req.body.comment
}
// insert data using SQL/MongoDB library
// refresh same page if success, the input elements cleared
// and show the success alert or fail alert div in rendered HTML
res.render('contact', {
fname : ''
lname : ''
...
comment : ''
});
});
是否有可能没有jQuery做到这一点?我不喜欢使用jQuery。