Example analysis of how to simply implement the jQuery pop-up effect
This article mainly teaches you how to simply implement the jQuery pop-up effect. It has certain reference value. Interested friends can refer to it. I hope it can help everyone.
The example in this article shares the specific code for jQuery pop-up window effect display for your reference. The specific content is as follows
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>弹窗</title> <script type="text/javascript" src="../jquery-3.2.1.min.js"></script> <style type="text/css"> *{margin: 0px;padding: 0px;} #login{height:300px;width: 300px;border: 1px solid #ddd;position: absolute; } #close{position: absolute;right: 0px;top: 0px;} </style> <script type="text/javascript"> // JS创建一个p标签,也就是节点元素 // window.onload=function(){ // document.createElement('p'); // } // 使用jQuery创建:$('<p>');带尖括号的是创建,不带是选择的意思 $(function(){ // var op=$('<p>'); // $('body').append(op); $('input').click(function(){ var oLogin=$('<p id="login"><p>用户名<input type="text"></p><p>密码<input type="text"></p><p id="close">X</p></p>');//此功能就相当于body中注释的代码 $('body').append(oLogin); oLogin.css('left',($(window).width()-oLogin.outerWidth())/2); oLogin.css('top',($(window).width()-oLogin.outerHeight())/2);//是弹窗能够出现在浏览器的中间 $("#close").click(function(){ oLogin.remove(); }) // jquery 中$()里window不用加引号 // 添加resize()浏览器窗口大小改变 // scroll():滚动条,以下的作用是当滚动条滚动时候,弹窗的位置也不变化 $(window).on("resize scroll",function(){ oLogin.css('left',($(window).width()-oLogin.outerWidth())/2+$(window).scrollLeft()); oLogin.css('top',($(window).width()-oLogin.outerHeight())/2+$(window).scrollTop()); }) }); }); </script> </head> <body> <input type="button" value="点击"> <!-- <p id="login"> <p>用户名<input type="text"></p> <p>密码<input type="text"></p> <p id="close">X</p> </p> --> </body> </html>
Points used:
jQuery creation: $(' ');
Pop-up window location:
oLogin.css('left',($(window).width()-oLogin.outerWidth())/2); oLogin.css('top',($(window).width()-oLogin.outerHeight())/2);
When the scroll bar scrolls, the position of the pop-up window changes:
$(window).on("resize scroll",function(){ oLogin.css('left',($(window).width()-oLogin.outerWidth())/2+$(window).scrollLeft()); oLogin.css('top',($(window).width()-oLogin.outerHeight())/2+$(window).scrollTop()); })
Related recommendations:
The pop-up window in H5 cannot How to solve the problem of pop-up using webview
How to use js in php to pass parameters to the pop-up window
Personalized web page small pop-up window
The above is the detailed content of Example analysis of how to simply implement the jQuery pop-up effect. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

The programming language PHP is a powerful tool for web development, capable of supporting a variety of different programming logics and algorithms. Among them, implementing the Fibonacci sequence is a common and classic programming problem. In this article, we will introduce how to use the PHP programming language to implement the Fibonacci sequence, and attach specific code examples. The Fibonacci sequence is a mathematical sequence defined as follows: the first and second elements of the sequence are 1, and starting from the third element, the value of each element is equal to the sum of the previous two elements. The first few elements of the sequence

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

In today's software development field, Golang (Go language), as an efficient, concise and highly concurrency programming language, is increasingly favored by developers. Its rich standard library and efficient concurrency features make it a high-profile choice in the field of game development. This article will explore how to use Golang for game development and demonstrate its powerful possibilities through specific code examples. 1. Golang’s advantages in game development. As a statically typed language, Golang is used in building large-scale game systems.

PHP Game Requirements Implementation Guide With the popularity and development of the Internet, the web game market is becoming more and more popular. Many developers hope to use the PHP language to develop their own web games, and implementing game requirements is a key step. This article will introduce how to use PHP language to implement common game requirements and provide specific code examples. 1. Create game characters In web games, game characters are a very important element. We need to define the attributes of the game character, such as name, level, experience value, etc., and provide methods to operate these

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

I'm really sorry that I can't provide real-time programming guidance, but I can provide you with a code example to give you a better understanding of how to use PHP to implement SaaS. The following is an article within 1,500 words, titled "Using PHP to implement SaaS: A comprehensive analysis." In today's information age, SaaS (Software as a Service) has become the mainstream way for enterprises and individuals to use software. It provides a more flexible and convenient way to access software. With SaaS, users don’t need to be on-premises
