如何仅使用jQuery(不使用其他插件)创建jQuery弹出窗口 [英] How to have a jQuery popup window using only jQuery (without other plugins)

查看:73
本文介绍了如何仅使用jQuery(不使用其他插件)创建jQuery弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道,我们是否只能使用jQuery而不使用Fancybox,Lightbox等其他插件来进行jQuery弹出.

I need to know, whether we can do jQuery popup only using jQuery without using other plugins like Fancybox, Lightbox, etc.

推荐答案

基本上,我认为您在谈论的弹出式样式只是绝对定位的元素,它的z-index值比页面上的其他任何元素都高:

Basically, the style of popup I think you're talking about is just an absolutely-positioned element with a higher z-index that anything else on the page:

$("<div style='z-index: 100; position: absolute; left: 100px; top: 100px; background-color: #ecc; border: 1px solid black'>Hi there</div>").appendTo(document.body);

在线示例

这些插件可能为您提供了许多有用的功能,包括:

There are lots of useful things that these plug-ins are likely to do for you, though, including:

  • 在页面其余部分的弹出窗口后面提供一个垫片",以防止在其他位置单击(如果您希望弹出窗口是有模式的).
  • 为垫片使用iframe,以便由于某些浏览器的问题,Flash动画和基于OS的表单控件不会显示在弹出窗口的顶部(即使它们在z顺序中应该较低)
  • 提供了一种关闭弹出窗口的内置方法(关闭框,Esc键等)
  • 提供自动居中

等.但是,如果您有充分的理由重新发明轮子(有时是 的原因),那么上面的内容应该可以帮助您入门.

Etc., etc. But if you have a strong reason to re-invent the wheel (and sometimes there is a reason), the above should get you started.

这篇关于如何仅使用jQuery(不使用其他插件)创建jQuery弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆