I am programming a survey online and want to delay the next button. I have the following code but I would like to improve it:
<script type="text/javascript">
$(document).ready(function(){
$("div.submit_div").slideUp(00).delay(10000).fadeIn(1000);
});
</script>"
I have two ideas, and will appreciate code for any of them:
-Is there any way to add a text that says "please note the button will appear in 10 seconds" while the button is being delayed?
-Is it possible to disable the button and present it with opacity, until the count down finishes and makes it possible to click it?
Assuming $("div.submit_div") to be the said button.
$(document).ready(function(){
$("div.submit_div").hide();
setTimeout(function() {
$("#init_text").remove();
$("div.submit_div").show();
}, 10000);
});
You can make one more div which shows the text you wanted to show while the button is hidden and manipulate that div similar to submit_div button.
Add <div id="init_text"> Please complete survey</div> before the code for the submit button.
Of course you can do it with success callback in animation.
<script type="text/javascript">
$(document).ready(function() {
$("div.submit_div").slideUp(00, function() {
/*
disable button here using `prop('disable',true)`
and do the rest
*/
}).delay(10000).fadeIn(1000, function() {
/*
enable button here using `prop('disable',false)`
and do the rest
*/
});
});
</script>
Related
I'm new to jQuery and been trying to figure this out.
I have a course assignment where I have to make an event handler for a page unload in JQuery that when fired will fadeout(3000) a div and then the text 'Thank you' will fadein(3000). I'm assuming what the instructor means is to have a button or link that leaves the window and goes to another page but first executes the fadeIn/FadeOut.
I'm not having any issues w/ the FadeIn/FadeOut option. I'm having the issue w/ the unload ... how do I get it to go to a new page but first execute a fadeOut(2000)/fadeIn(2000)?
I'm having a problem figuring this out. As far as I understand unload is compatable only w/ $(window), so the only that I can really do is have an alert?
This is what I have so far, but this is not an unload, I'm trying to figure out how to have this effect work once you are unloading. Is that even possible?
JQ
$(function () {
$(".btn1").click(function () {
$("#fadeout").fadeOut(3000);
$("#thankyou").fadeIn(3000);
});
});
CSS
btn1 {
display:none;}
HTML
<button id="btn1" class="btn1">CLICK</button>
Would I add a delay to close the window and link something else at the same time when you hit the button?
$(".btn1").click(function() {
$("#fadeout").fadeOut(3000, function() {
$("#thankyou").fadeIn(3000, function() {
location="url";
});
});
});
#thankyou {
display: none
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='fadeout'>Hello World!</div>
<div id='thankyou'>Thank you!</div>
<button class='btn1'>Click</button>
This?
I have a problem with my updateprogress. Its working, but I want a close button to close it. Its not problem yet, but I want to display this button after display of updateprogress in 30 sec. I tried do it with jquery, but it didnt work.
Can you help me?
Here is a sample. My problem is, that I dont know, what kind of event show the updateprogress.
$('.UpdateProgress').on('display', function () {
$('.btnClose').hide(0).delay(30000).show(0);
});
I tried display, show, focus event, but I dont know how to do this.
Set your button to hidden to start:
<style>
input.btnClose
{
display: none;
}
</style>
<input type="submit" class="btnClose">
Now use setTimeout to show() it after 30000ms (30 seconds):
<script type="text/javascript">
$(document).ready(function(){
$('.UpdateProgress').on('display', function () {
setTimeout("showDelay();", 30000);
});
});
function showDelay() {
$('.btnClose').show();
}
</script>
I want to make a login slider with jQuery. You will have a div at the top of your page with a plus image. I want the plus image to be changed into a minus image and the div will slide down. Here is my code but there is a problem.
<script src="_js/jquery-1.7.2.min.js"></script>
<script>
$(document).ready(function() {
$("form").hide();
$(".open").click(function() {
$("form").slideDown("slow");
$(".open").addClass("close");
$(".close").removeClass("open");
$(".close").click(function() {
$("form").slideUp("slow");
$(".close").addClass("open");
$(".open").removeClass("close");
});
});
});
</script>
It works once but if you want to slide it down for the second theme it doesn't work anymore.. Can somebody help my please?
tnx!
Working JSFiddle
Try something different like the following:
$('.open').click(function () {
$('form').slideToggle('slow', function () {
$('.open').toggleClass('form-is-open');
});
});
jQuery offers some toggle functions which supply the desired behaviour. This way you don't need two click handlers or keep track of classes yourself. The above code simply adds a class ('form-is-open') to the button, when the form is shown and removes it, when it is hidden.
Ok this is my problem that no one can seem to answer. I have two javascripts in use. Once is for the popup I have and tells it to stay closed for 24hrs when closed. The other is to put a link some where on the page to display this popup until refreshed and kept hidden till the cookie expires. Now the div popup is set to display:none. The cookie tells it to be shown until the close button is pressed. No matter what I seem to rework in my javascript to tempoarly show the popup from a link, it will not show. Some how the cookie javascript is going to have to be modified and thus having to remove css:display:none on the popup div. I have no idea what to do.
This is the current code:
http://jsfiddle.net/Dv7DR/-
http://pastebin.com/fHvv5spn
<script type="text/javascript">
$("#linkshow").click(function {
$("#window").show()
});
</script>
Submit a comment
<div id="window">
...
<div>
<script type="text/javascript">
...cookie popup hide for 24hr on close
</script>
Note: I have already tried:
$(document).ready(function() {
$("#linkshow").click(function(e) {
e.preventDefault();
$("#window").show();
});
});
and...
$(document).ready(function() {
$("#window").hide();
$("#linkshow").live('click', function(e) {
e.preventDefault();
$("#window").show();
});
});
and...
$(function() {
$("#linkshow").click(function() {
$("#window").show()
});
});
and...
<div id="window" style="display:none;">
to
<div id="window">
Then the other 24hr cookie javascript doesn't keep the popup hidden. I am assuming I need to take out the id="window" style="display:none; and some how advanced the javascript cookie at the bottom the code so it will hide when asked to be hidden for 24hr and show when needed to be shown on the current page until refresh but I am at blank on what to do.
Your syntax is wrong, Try
$(document).ready(function() {
$("#linkshow").click(function(e) {
e.preventDefault();
$("#window").show();
});
});
Works for me: See jsFiddle
You need to wrap your code in a DOM ready handler, and you also missed the brackets following the function declaration. Try this:
<script type="text/javascript">
$(function() {
$("#linkshow").click(function() {
$("#window").show()
});
});
</script>
I have 3 show more links in my layout. They must trigger all the same table with content. So when you click on link 1 it shows the table, but if you click on link 2 the table won't be hidden again (only when I click 2 times).
How can I fix this?
My code I have now:
$(".starterlink").toggle(
function(){ $(".starterinfo").fadeIn('fast'); },
function(){ $(".starterinfo").fadeOut('fast'); }
);
If I understand your question correctly, why don't you do something like:
$(".starterlink").click( function(){ $(".starterinfo").fadeToggle('fast'); } );
Updated:
The following test code works fine for me.
Click me
<div class="starterinfo">This will fade in and out</div>
<script type="text/javascript">
$(".starterlink").click(function () { $(".starterinfo").fadeToggle('fast'); });
</script>
toggle() function has no toggle(function, function) signature. IE it doesn't take two functions as arguments.
Maybe something like
$("#link1").click(function(){
$("#tableid").attr('visible', false);
});
$("#link2").click(function(){
$("#tableid").attr('visible', true);
});