我在动态创建的元素上的点击事件上使用 JQuery 时遇到问题。
动态创建的代码是这样的:
<div class="container rounded">
<div class="message_area" style="background-color: #dff0d8;border:1px solid #d6e9c6; color: #3c763d">
<button class="close" type="button">x</button>
Ya esta suscrito a nuestras listas de envío, sus datos han sido actualizados.
</div>
</div>
当客户端单击关闭按钮时,我正在尝试更改容器(bloqFormulario 类)的高度。
我尝试过以下选项:
(function($){
$(".close").click(function() {
$(".bloqFormulario").height(200);
});
})(jQuery);
(function($){
$(".message_area").on("click", "button", function() {
$(".bloqFormulario").height(200);
});
})(jQuery);
但我没有结果。
你能帮我吗?
非常感谢。
最佳答案
像这样使用
$(function(){
$(document).on("click",".close",function() {
$('.bloqFormulario').css("height","200px");
});
});
关于JQuery 动态创建元素上的单击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35536945/