C# Jadu
  • Home
  • Asp.net
  • Web Design
    • Html
    • Css
    • Java Script
  • Bootstrap
  • Sql
    • Queries
    • Stored Procedures
  • About Me
    • About Myself
    • My Projects
    • My CV
  • Gallery
  • Do you Know?

Wednesday, 3 February 2016

Create a Pop-up div in jQuery

 Deepak Chaudhary     10:07     Css, Js     No comments   

Hi Friends...

This is an easy tutorial suitable for those fairly new to jQuery. This tutorial will teach you how to create a simple pop-up effect, showing a hidden div, when you hover over the trigger link. jQuery Tutorial - Pop-up div on hover

Pop-up div on hover

hover your mouse over Hover Me.

I am Pop-up div

I only appears when the trigger link is hovered over. Otherwise I will Disappear.

Your Code is as under

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>jQuery Tutorial - Pop-up div on hover</title>
    <style type="text/css">
        body {
            margin: 0;
            padding: 0;
            font-family: Arial, Helvetica, sans-serif;
            background: #fff;
            color: #000;
        }
        h1, h3 {
            margin: 0;
            padding: 0;
            font-weight: normal;
                  }
        a {
            color: #ff6a00;
            }
        div#container {
            width: 285px;
            margin: 50px auto 0 auto;
            padding: 20px;
            background: #fff;
            border: 1px solid #1a1a1a;
        }
        div#pop-up {
            display: none;
            position: absolute;
            width: 275px;
            padding: 10px;
            background: #fff;
            color: #000000;
            border: 1px solid #1a1a1a;
            font-size: 90%;
        }
    </style>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            var moveLeft = 20;
            var moveDown = 10;

            $('a#trigger').hover(function (e) {
                $('div#pop-up').show();
                
            }, function () {
                $('div#pop-up').hide();
            });

            $('a#trigger').mousemove(function (e) {
                $("div#pop-up").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
            });
        });
    </script>
</head>
<body>
    <div id="container">
        <h1>Pop-up div on hover</h1>
        <p>
             hover your mouse over
      <a href="#" id="trigger">Hover Me</a>.
        </p>
    </div>
     <!-- HIDDEN / POP-UP DIV -->
      <div id="pop-up">
        <h3>I am Pop-up div </h3>
        <p>
          I only appears when the trigger link is hovered over. Otherwise
          I will Disappear. 
        </p>
      </div>
</body>
</html>

Thank You !


  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Most Popular posts

  • How To Create Image wipe Effect With CSS3 Webkit Animation
    Hi Friends... In this article we learn how to create a Image wipe effect with CSS3. CSS transition and animations provide a way for web de...
  • CSS 3D Cube
    Hi Friends... CSS cubes really showcase what CSS has become over the years, evolving from simple color and dimension directives to a lang...
  • CSS 3D Transforms
    Hi Friends... There is nothing more flashy and full with eye-candy than an impressive 3D CSS demo. Although its utility outside of demos ...

About Me

Deepak Chaudhary
View my complete profile

Copyright © C# Jadu | Powered by Blogger
Design by Deepak Chaudhary