What you'll be creating: [Only registered and activated users can see links. Click Here To Register...]
An exact replica of the preview page: [Only registered and activated users can see links. Click Here To Register...]
Or stripped down version without the random stuff.
Spoiler for Snippets:
HTML:
[SPOIL]
Code:
<div class="button" data-name="name">Show Box</div>
<div id="bg" class="name">
<div class="button_close" data-name="name">Close</div>
<div id="popup" class="name">
A popup box designed to be re-used as many times as you like. Defined through the <i>data-name</i> attribute within the buttons.
</div>
</div>
$(document).ready(function(){
$('.button').click(function(){
var name = $(this).data("name");
console.log(name);
$('.'+name).fadeIn();
$('.'+name).fadeIn();
});
$('.button_close').click(function(){
var name = $(this).data("name");
console.log(name);
$('.'+name).fadeOut();
$('.'+name).fadeOut();
});
});
[/SPOIL]
The JQuery uses the data-name attribute to select the popup box you're wanting to pull up, it was originally made for a friend to use in their store(using a while loop) so it'd be easier to implement.
06-24-2015, 06:35 PM
Mr. Robot
Good job! nice release
06-24-2015, 06:39 PM
Max _
Nice one, thanks for this mate.
06-26-2015, 11:14 PM
OG KingFox
Quote:
Originally Posted by DynamicGFX[Only registered and activated users can see links. Click Here To Register...]
JQuery Pop-Up Box - Snippet
What you'll be creating: [Only registered and activated users can see links. Click Here To Register...]
An exact replica of the preview page: [Only registered and activated users can see links. Click Here To Register...]
Or stripped down version without the random stuff.
Spoiler for Snippets:
HTML:
[SPOIL]
Code:
<div class="button" data-name="name">Show Box</div>
<div id="bg" class="name">
<div class="button_close" data-name="name">Close</div>
<div id="popup" class="name">
A popup box designed to be re-used as many times as you like. Defined through the <i>data-name</i> attribute within the buttons.
</div>
</div>
$(document).ready(function(){
$('.button').click(function(){
var name = $(this).data("name");
console.log(name);
$('.'+name).fadeIn();
$('.'+name).fadeIn();
});
$('.button_close').click(function(){
var name = $(this).data("name");
console.log(name);
$('.'+name).fadeOut();
$('.'+name).fadeOut();
});
});
[/SPOIL]
The JQuery uses the data-name attribute to select the popup box you're wanting to pull up, it was originally made for a friend to use in their store(using a while loop) so it'd be easier to implement.
pretty sure theres no need to fade in/out the inner elements, as fading out the enclosing elements will also hide the inner
also, different elements should have unique ids
<div id="bg" class="popup">
<div class="button close" data-close="bg">Close</div>
<div class="popup-box">
A popup box designed to be re-used as many times as you like. Defined through the <i>data-name</i> attribute within the buttons.
</div>
</div>
Code:
$(document).ready(function() {
$('.open').click(function(){
var name = $(this).data("open");
$("#"+name).fadeIn();
});
$('.close').click(function(){
var name = $(this).data("name");
$("#"+name).fadeOut();
});
});
Also, you can use two classes on one button, such as "button open" and "button close"