anthelo Posted September 17, 2012 Share Posted September 17, 2012 Now my button is auto shown after 1min, how i can make it to be visablee after 0min & 41second <body> <button>My button</button> </body> function enableButton() { $("button").prop("disabled", ""); } $(function() { var minutes = 1; // time to be disabled var time = minutes * (1000 * 60); $("button").prop("disabled", "disabled"); // Disable the button onload setTimeout(function() { enableButton(); }, time); }); Live demo: http://jsfiddle.net/RrBKr/9/ Regards Quote Link to comment Share on other sites More sharing options...
Christian F. Posted September 17, 2012 Share Posted September 17, 2012 Tried reading the code? It is fairly self-explanatory, after all. Quote Link to comment Share on other sites More sharing options...
anthelo Posted September 17, 2012 Author Share Posted September 17, 2012 ChristianF , why do you even reply if you dont know/want to help?? Ignore it and move forward, we are not that smart like you are sorry Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 17, 2012 Share Posted September 17, 2012 DID you read the code? It IS incredibly obvious. You need to change 2 lines, there's a few ways you could do it. If someone does it for you, you won't learn. Quote Link to comment Share on other sites More sharing options...
codefossa Posted September 23, 2012 Share Posted September 23, 2012 They ain't bein' mean. You just need to try and think for yourself rather than ask someone to fix everything for you. This is not a site where people do work for you, they help you with your own work. The only thing you should possibly need help on is knowing the time is in milliseconds. This means that 1000 is a second. So, 60 * 1000 is a minute. Also, please change the variable name to seconds just because it'd drive me mad if you left it as minutes. And that should tell you exactly how to do it. Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted November 20, 2012 Share Posted November 20, 2012 Let me start by saying that you should make it a point to go to your favorite book store and get your hands on an introductory level javascript book. Your understanding of programming is obviously very rudimentary and such a book would be a good place to start and give you a solid foundation on which to build. The members of this forum are here to help, and though it may seem that their comments were derogatory in nature, they said what they did with the greatest of intentions. Someone with a solid foundation in the basics of programming should quickly realize that "var time" holds the amount of time they are looking for and had you put some more time into considering the code and what it was doing and what you wanted it to do, this should have become apparent. It is like a teacher giving you hints and suggestions to get you to figure things out for yourself and learn rather than just handing you an answer sheet with all the correct answers for the test. If someone just told you the answer was var time = 41000; then you would learn nothing. Now let me explain why this is the case. In the code you have var minutes is a human readable, easy to understand representation of time. There is no tricky math required to know that if you want the button to become enabled in 1 minute the value should be 1 and for 5 minutes the value should be 5. The time variable (var stands for variable and is how variables are defined in javascript) does the tricky math since javascript measures the passage of time in milliseconds. var time = minutes * ( 1000 * 60 ); means that we take the number of minutes and multiply it by the number of milliseconds in a minute, so that's 1 x ( 1000 x 60 ). From math we know that we process the parenthesis first so it becomes 1 x ( 60000 ) which is simply 60000 milliseconds in 1 minute. If we were doing 5 minutes it would be 5 x 60000 which would be 300000 milliseconds in 5 minutes. If we want 41 seconds in a time format that javascript can work with it would be 41 x 1000 which is 41000. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.