Background wont change back - javascript

So I have this video background when you first load the page up and then there's a button you click that overlays what's visible and puts a div that's the pages height, when you hide the div afterwards the video that I had is gone and a white background is present instead, why's that? thanks for help.
$( document ).ready(function() {
var yellowclicks = 0;
$('.x').hide();
$('.yellow-text-bg').hide();
$('.round-button-circle-x').hide();
$('.round-button-circle').click(function(){
$('.round-button').css('margin-top','5%');
$('#logo').fadeOut(80);
$('.hiderow').hide();
$('.round-button-circle').hide();
$('.yellow-text-bg').delay(80).fadeIn(500);
$('.round-button-circle-x').delay(80).fadeIn(500);
yellowclicks =+1;
$('.intro').hide();
});
$('.arrow').click(function(){
$('.yellow-text-bg').fadeOut(400);
$('#logo').delay(500).fadeIn(500);
$('.round-button-circle').delay(500).fadeIn(500).css('margin-top','10%');
});

Related

Content is overlapping with Menu

Create a html page for mobile some part of content is showing on Menu bar.
Only the bottom content is showing on menu bar how to avoid it ?
and also I want to disable scroll-bar when menu button is clicked & enable when content is touched using Mobile.
I tried below code but its disabliling but not enabling scrollbar when content screen is clicked on mobile :(
My Javascript :
$(document).ready(function() {
scrollTopPos = $( document ).scrollTop();
allowScrolling = true;
$(document).scroll(function() {
if(allowScrolling === false) {
$( document ).scrollTop( scrollTopPos );
} else {
}
});
$( "#mobile-toggle" ).click(function() {
$('body,html').css('overflow', 'hidden');
$("#divCls").css('display','None')
});
$(document).on('touchmove', function(e) {
e.preventDefault();
showDiv()
});
});
function showDiv() {
document.getElementById('divCls').style.display = "block";
}
It's hard to tell without the full code, but in terms of keeping the menu at the front you can just use CSS to se the Z-index of the DIV. In terms of the scroll, add a CSS rule trigger within your JavaScript to set Overflow to Hidden then set it back to scroll when you click the close button.
Also, if only parts are spilling over then be weary of the page size, if you're using a slide in menu that is hidden to the side then slides the whole page over, then mobile users can swipe it shut but the open button will not work unless you use the jquery swipe functionality so again, the z index and a bit of doodling with the script to make the menu sit over the page would fix this. Again, more script would be handy :P

Javascript to make div appear after scroll is showing on page load?

I input this code (which I pulled from this answer: Make a div appear when scrolling past a certain point of a page) to make a div appear when the user scrolls down on the page.
The problem is: The div appears as soon as the page loads, and disappears when the user scrolls, and then reappears when they scroll > 700.
How do I get the div to not show up at the beginning of the page load?
Thanks!
<script>
// Get the headers position from the top of the page, plus its own height
var startY = 700;
$(window).scroll(function(){
checkY();
});
function checkY(){
if( $(window).scrollTop() > startY ){
$('.scroll-up').slideDown();
}else{
$('.scroll-up').slideUp();
}
}
// Do this on load just in case the user starts half way down the page
checkY();
</script>
In your CSS set display:none property for the div you don't want to show on page load
Instead of slideUp() and slideDown()
you can use, fadeIn() and fadeOut() or slidetoggle();

Change slider image in Click

in my page i have a thumnails list of images and a background image, basically what im attempting to do is when one of the thumbnails images are clicked the background image changes. But for i cant figure out why its not change the image.
When the thumbnail image is clicked the background image gets faded but it doesnt replace the image for the new one. Above i leave my code:
thumb-img id the Thumbnails id
and #banner is the wrapper of the background imagem.
Example: http://jsfiddle.net/q6h50ejq/6/
$('#thumb-img').click(function(){
$this = $(this);
$image = $this.attr('full');
$("#banner").hide().html('<img class="item_image" src="img/newImage.jpg">').fadeIn(300);
});
});
Here is the completed results with commented explanation.
JSFiddle
The trick is not to replace the html, but replace the src.
//use a class rather than an ID to bind the click event
$('.thumb-img').click(function () {
//gets the source of the thumbnail
var source = $(this).attr('src');
$("#banner").fadeOut(function () {
//fades banner out and upon completion changes source image and fades in.
$(this).attr("src", source);
$(this).fadeIn();
});
});

Animate showing and hiding login box

I am trying to create a jquery animated loginbox.
I am a total javascript/jquery noob.
I have a div that contains the loginbox. That div is about 150px in height, and it is placed at the top of the page, so that only the bottom 15px of the div are visible when the page is loaded.
I am trying to slide down the div so that the rest of the login box is revealed on click, and make it slide back up when the bottom part of the div is clicked again.
Now, I am doing:
$('#showLogin').click(function(e){
$('#formContainer').animate({top: "+=135px"} , 1500)
e.preventDefault()
})
What this does is animate the slide down of the div. But how can I check if it has already been slided down so I can slide it back up?
Should I check for the position of the div and decide if it should move up or down, or is there a better way to do it?
The website is here
I think you are looking for .slideToggle(). An example: http://jsfiddle.net/FL4zZ/
Try this jsFiddle example. It animates a div with a form within it on click, and retracts it once it's fully extended.
The basic jQuery is:
$('div').click(function() {
var pos = $(this).css('top')
if (!$(this).is(':animated')) {
if (parseInt(pos, 10) == 0) {
$(this).animate({'top': '-35px'}); // anim up
}
else {
$(this).animate({'top': '0px'}); //anim down
}
}
});

mouseout set previus returns previous bg image of div

all.
I have.
<div id="imagecontainer" class="header-image-container"> </div>
BG image are specified in css for ich page according on parent class.
.category-1 #imagecontainer {
background: url(_/images/1.jpg);
}
And i have menu. I want to chage BG image ommouse over, and on mouse out return image specified in css for this page according on parent class. I think it could be real using JQuery. For example we have opened category-3 page and move mouse on category-1 menu item and see catefory-1 BG image in #imagecontainer, and then we move mouse out see again category-3 BG image.
I think this will do you want:
$('#menu').mouseenter(function() {
$('#imagecontainer').css({'background':'blue'});
}).mouseleave(function() {
$('#imagecontainer').removeAttr('style');
})
You can see it in action here: http://jsfiddle.net/Cdzk8/
If you have other inline styles on your imagecontainer, it will also remove those on mouseleave. In that case, you will have do something more like what mblase75 is recommending.
Store the current background image as data before swapping it out, and retrieve it from there when you want to swap it back.
$('#imagecontainer').mouseover(function() {
$(this).data('bgimg') = $(this).css('background-image');
$(this).css('background-image','url(my/new/url.jpg)');
}).mouseout(function() {
$(this).css('background-image', $(this).data('bgimg'));
});

Categories

Resources