i try to use This code.
It works good with 1 window, but i need 2 popup window.
i try to modified it like this
$(document).ready(function(){
PopUpHide();
});
function PopUpShow(){
$("#popup1").show();
$("#popup2").show();
}
function PopUpHide(){
$("#popup1").hide();
$("#popup2").hide();
}
And HTML
<div class="b-container">
Sample Text
Show popup
</div>
<div class="b-popup" id="popup1">
<div class="b-popup-content">
Text in Popup
Hide popup
</div>
</div>
<div class="b-container">
Sample Text
Show popup
</div>
<div class="b-popup" id="popup2">
<div class="b-popup-content">
Text in Popup
Hide popup
</div>
</div>
Where i make mistake?
You're most probably showing two popups above each others, give one of them different position and class and use different Javascript function to show each, or send a variable to the function to decide which one to view.
Would be something like that:
function popupshow(whichOne)
{
if(whichOne == 'first'){
$("#popup1").show();
$("#popup2").hide();
}
else{
$("#popup1").hide();
$("#popup2").show();
}
}
UPDATE: here's the fiddle code as you requested. http://jsfiddle.net/jBf2y/2/
Your code above is working. You just need to set a margin to #popup2 div.
They bot appear together, but as they are in the same position, you only see one of them.
$(document).ready(function(){
PopUpHide();
});
function PopUpShow1(){
$("#popup1").show();
function PopUpShow2(){
$("#popup2").show();
}
function PopUpHide(){
$("#popup1").hide();
$("#popup2").hide();
}
In the end i make like this
Related
How would I create a welcome screen on my web site? For Example: I have an image and a link that says "ENTER" when the user clicks enter the web site appears. How would I do that? Also if possible with JavaScript or JQuery, When the user clicks "ENTER", would it be possible to crossfade from the splash screen to the web site? I want that the link be functional within any element/tag on the DIV splash.
I have this code:
$('.Intro').click(function()
{
$(this).parent('#Intro').fadeOut(1000);
});
But it only works with:
<DIV id="Intro">
ENTER
</DIV>
And not with:
<DIV id="Intro">
<DIV class="EnterII">
ENTER
</DIV>
</DIV>
Therefore, just within the DIV Intro...
Why do you need to complicate?
As identifiers must be unique. Simply use ID selector
$('#Intro').fadeOut(1000)
<DIV id="Intro">
<DIV class="EnterII">
ENTER
</DIV>
</DIV>
With a little bit of indentation you can see that in this case the parent() function will return EnterII so that is the div that will be faded out. Use jquery closest() in order to get intro
$('.Intro').click(function(){
$(this).closest('#Intro').fadeOut(1000);
});
Have you tried just:
$('#Intro').fadeOut(1000);
instead of
$(this).parent('#Intro').fadeOut(1000);
I have a generic piece of html code with form fields which I reuse in several places. When opened inside a bootstrap modal I would like the content to fill the entire modal, but when used elsewhere I don't want it to be as wide. I wanted to do this using ng-class, using code like this:
<div ng-class="modal ? 'col-sm-9' : ['col-sm-9 col-lg-5']">
content...
</div>
The problem is: how do I check if the code is inside a modal or not? Is there some function I can call or some variable to read? I would like to avoid populating all modal-controllers with some isModal() function.
I would recommend using CSS for this. The browser would then identify if the snip-it appears within an element defined as the modal and the correctly apply the style.
Assuming you are using LESS with your bootstrap implementation an example is below. But it should give you a general idea either way.
LESS CSS markup:
div.content {
.col-lg-5
}
modal {
div.content {
.col-sm-9;
}
}
HTML:
<div class="modal">
<h1>Heading</h1>
<div class="content">
content...
</div>
</div>
Give id= "mymodal" to the div.
Then in script create a click function and call this div by id :
$("#mymodal").show();
The modal shows with its content.
I'm having a little trouble here and hopefully someone can give me a hint on what I'm doing wrong. The object within the main div is hidden and I need it show when I click the button within the secondary div. I'm getting the secondary div to "close" after the button is clicked but I just can't seem to figure out how to make the "checked" object to show.
Here is the HTML:
<div class="separate">
<div class="main">
<h1>Mechanical Room</h1>
<object class="checked"></object>
</div>
<div class="secondary">
<div class="heading">
<h2>Mechanical Room</h2>
<button class="check-in">Check In</button>
<object></object>
</div>
</div>
</div>
And here is my jQuery code:
$(document).ready(function() {
$(".check-in").click(function () {
$(this).closest(".separate").children(".secondary").fadeOut(200);
$(this).closest(".separate").children(".main").find("object").show();
});
});
If your div is set to hidden by visibility then show() method won't show demo
You need to set .css('visibility','visible'); then.
$(document).ready(function() {
$(".check-in").click(function () {
$(this).closest(".separate").children(".secondary").fadeOut(200);
$(this).closest(".separate").children(".main").find("object").css('visibility','visible');
});
});
It is working just fine in my fiddle.
Did you style your object?
Did you make sure it's hidden initially?
$("object").hide();
I added [THE OBJECT] as it's content to see it.
<object class="checked">[THE OBJECT]</object>
Demo: http://jsfiddle.net/u6x84/
I have many questions here so please be patient with me, very new jquery/javascript user.
Here is my current page http://integratedcx.com/index.php/experience
Basically I would like each of the projects and project categories to have the hidden div, slidedown like a drawer not just appear as they do now.
I have tried to achieve this through jquery without much success, here is my working http://integratedcx.com/temp/slide.html
How do I get the div below the one opening to "ease" down instead of jump
How do I get my close feature (orange box) in recent projects to work properly
How do I get my the project list on the right side of image to hide (as it does on my current page) as well as have the drawer opening effect.
Is there an easy way to i.e. variable to assign this to multiple divs using jquery.
Thank you in advanced for any/all help.
For your question 4, With the following script (based on ComputerArts's answer above), you can easily add the slide effect to a large number of divs:
$(document).ready(function () {
$(".toggle-to-show").click(function (evt) {
var targetdiv = $(evt.currentTarget).attr("data-drawer");
$(targetdiv).slideToggle(1000, function() {
if ($(this).is(':visible')) {
$('.bracket', evt.currentTarget).html('less');
$('.project', evt.currentTarget).hide();
$('.closebox', this).bind('click', function(e) {$(evt.currentTarget).triggerHandler('click');});
}
else {
$('.bracket', evt.currentTarget).html('more');
$('.project', evt.currentTarget).show();
$('.closebox', this).unbind('click');
}
});
})
})
Then, you can mark up the toggle buttons and sliders as follows:
<div class="toggle-to-show" data-drawer="#firstsection">
<div class="project">Project One Heading</div>
<div class="bracket">more</div>
</div>
<div id="firstsection">
<h3>Project One Heading</h3>
stuff
<img class="closebox" src="close.jpg">
</div>
<div class="toggle-to-show" data-drawer="#secondsection">
<div class="project">Project Two Heading</div>
<div class="bracket">more</div>
</div>
<div id="secondsection">
<h3>Project Two Heading</h3>
stuff
<img class="closebox" src="close.jpg">
</div>
<div class="toggle-to-show" data-drawer="#thirdsection">
<div class="project">Project Third Heading</div>
<div class="bracket">more</div>
</div>
<div id="thirdsection">
<h3>Project Three Heading</h3>
stuff
<img class="closebox" src="close.jpg">
</div>
As for points #1 and #2, try this fiddle
I only changed the first script tag to
<script type='text/javascript'>
$(document).ready(function () {
$(".projectx-show").click(function () {
$("#projectx").slideToggle(1000, function() {
if ($(this).is(':visible')) {
$('#projectx-bracket').html('less');
}
else {
$('#projectx-bracket').html('more');
}
});
})
})
</script>
FYI, you don't need to use $(window).load and then $(document).ready... one is enough
As for #3, I don't understand what you're trying to say.
#4, yes there is a way, using classes and keeping the structure the same for every bloc in your page.
http://api.jquery.com/slideDown/
$("#link_id").click(function(){
$("#div_to_show").slideDown();
});
http://api.jquery.com/slideUp/
$('#div_to_close').slideUp();
Using both of the methods from 1, and 2
By using class names instead of IDs for your selectors. For example:
$(".link_class").click(function(){
$(this).parentsUntil('.ex-wrapper').find('.div_to_show').slideDown();
});
I am using the below javascript (jQuery) to toggle open two DIVs. The DIVs open fine and open one at a time, which is what I am after. However, I also want the DIVs to close when they are clicked a second time, which doesn't happen despite my best efforts!
Javascript:
$(document).ready(function() {
$('.info_tab').click( function() {
var currentID = $(this).next().attr("id");
$('.toggle_info[id!=currentID]').hide(); /* the intention here is to hide anything that is not the current toggling DIV so as to close them as a new one is opened. I thought this would leave the currently selected DIV uninterrupted to toggle closed (below), but it doesn't */
$(this).next().toggle();
return false;
});
});
HTML:
<div class="info_tab">
<h1>Person One</h1><br />
<p>click for less info</p>
</div>
<div id="person_one_info" class="toggle_info">
<p>More information about Philip Grover</p>
</div>
<div class="info_tab">
<h1>Person Two</h1><br />
<p>click for less info</p>
</div>
<div id="person_two_info class="toggle_info">
<p>More information about Roy Lewis</p>
</div>
If any more info is needed, just ask and I'll be happy to edit the question.
Cheers,
Rich
you have the concept down, but not using the "currentID" correctly. You need to remember it's a variable, and can't be in another string if you want it evaluated.
With that said, try this:
$('.toggle_info[id!='+currentID+']').hide();
This makes the variable get evaluated in the selector, then passes it off to jQuery to find.
it looks like you're going to an accordian effect though. And jQuery UI has just such a control that you can use (if you're interested). if you're going for experience, then carry on. ;-)