对于一个艺术家的广场网站,试图显示一个按钮在灯箱,以便用户可以发送一个直接的信息,关于一个他们喜欢的作品。
我可以让按钮显示时,一个图像拇指被点击,但似乎不能让按钮隐藏时,灯箱关闭。
**我一开始在香草JS试过,但不得不去jQuery ¯\_(ツ)_/¯ 查看jsFiddle
在thumb-image上显示“联系人”按钮,单击:
$('.thumb-image').click(function () {
var content = $("body").find('.form-block');
content.addClass("toggle-content");
});我试图把灯盒上的按钮藏起来。
$('.featherlight-close').click(function () {
var hideButton = $("body").find('.form-block');
hideButton.addClass("toggle");
});我的思维过程的分解:
- _lightbox is originally not present on the page, it is loaded by JavaScript directly below the opening_ `body` _tag_.
- _trying to display the contact button by jQuery's_ `addClass` _method and this class_.切换-内容{显示:块;}
- _the close "X" is on a pseudo element, and I found this to really complicate things :|_ 光明盒-关闭:前
非常感谢你在这方面的帮助。
发布于 2018-09-05 14:55:24
您必须删除现有的类并为切换类添加新的类。
$('.thumb-image').click(function () {
var content = $("body").find('.form-block');
content.removeClass("toggle");
content.addClass("toggle-content");
});
$('.featherlight-close').click(function () {
var hideButton = $("body").find('.form-block');
hideButton.removeClass("toggle-content");
hideButton.addClass("toggle");
});https://stackoverflow.com/questions/52187986
复制相似问题