单击按钮时打开弹出框
PopBox 插件对于在以下情况下在其自己的窗口中弹出文本区域非常有用:您在文本区域内单击。但是,我希望当用户单击按钮时出现 PopBox,而不是出现在文本区域内。有没有办法为此修改 PopBox 功能?
tl;dr:我希望 PopBox 在调用函数时弹出,而不是在文本区域内单击时弹出
The PopBox plugin is useful for having a text area pop up in its own window when you click within a text area. However, I want a PopBox to appear when the user clicks a button, rather than within a text area. Is there a way to modify the PopBox functionality for this?
tl;dr: I want the PopBox to pop when a function is called rather than when clicking inside a text area
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看 popBox 源,您会看到popBox 应用于一个元素(通过
$('#yourElement')).popBox()
,有一个focus
事件绑定到它:将一个 click 事件附加到您的按钮,然后在其中触发popBox 通过触发上面提到的
focus
事件:在此处查看工作演示
显然,您可以修改它以满足您的需求 - 例如,如果您不希望显示初始的
textarea
或input
,则隐藏它。If you look at the popBox source, you'll see that when popBox is applied to an element (via
$('#yourElement')).popBox()
, there is afocus
event bound to it:Attach a click event to your button and, within that, trigger the popBox by triggering the above mentioned
focus
event:See a working demo here
Obviously, you can modify this to fit your needs - e.g. hiding the initial
textarea
orinput
if you don't want it displayed.