Jump to content

kodejuice

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by kodejuice

  1. The first one could be called anywhere within the scope it is defined in, while the second can not.
  2. Do you mean enumerating the items in the window object, if so here is how. for(var k in window){ console.log(k '\n'); }
  3. You dont need arrays for such tasks, try this //using jQuery $(function(){ var total = 0; $("input[type=checkbox]").click(function(){ var disVal = $(this).val(); total += Number(disVal); alert(total); }); $(".resetButton").click(function(){ total = 0; //reset }); });
  4. Can someone become a web developer and a software developer, and be very good at both, I need replies please.
  5. Please i need to know what every web designer must know before he/she can say "I'm a web designer", i want to know if technologies like HTTP,PhotoShop,DNS are neccessary, Please i need to know
  6. Please can one briefly explain the use of this sign in javascript, and what is results to.I.e var d = 5;return d >> 1; //=> 10why is it '10'?
  7. Items returned by the prompt function are strings so you have to convert it to a number with the "Number" function.<script>function q(){ var a = Number( prompt("Enter value") ); var b = Number( prompt("Enter value") );document.getElementById("demo").innerHTML= a + b;};</script><button onclick="q()">Click on me</button><p id="demo"><p>
  8. Thanks alot, please can you recommend any algorithm/data structures book for a javascript programmer.
  9. i need to know if i would learn about algorithms and data strcutures in order to be called a JavaScript programmer/* Please i'm so so confused */
  10. I'm actually dealing with netscape and not IE
  11. Please how do i accomplish this, an equivalent to jquery .find function/*My Try*/function find(parent, child){ return document.querySelector(parent).querySelector(child);}<ul> <li>First</li></ul>find("ul","li"); //[object LI]//this works fine but, the support for "document.querySelector" is limited, i need and equivalent please.
  12. Please how do i get around with this - I need a function that waits for like 2 seconds before moving on to the next line./*My Attempt*/function waitFor(secs){ return setTimeout(function(){ //waiting...}, (secs||1000));}alert("code started");waitFor(2000);alert("code stopped");
  13. <section id="first"> <!-- use for Ajax --> <form method="get" action="" id="add1"> <fieldset>JS Code $(document).ready(function(){ $("section#first").show(); });
  14. Please i need help toggling between two functions, here is my attempt.<script> toggle = true; function toggleFunc(fn1, fn2){ if(toggle == true){ fn1.call(fn1); toggle = false; } else{ fn2.call(fn2); toggle = true; } }</script>This works perfect, but i can't have more than one "toggleFunc" function on a page.
  15. Hey fuys, please i need help on how to accomplish this witout the use of Jquery .slideUp() method
  16. The above code is meant to compile my code in a script tag with an id of "#val", if i read the code by line, it wont work out, cause it also read "while(!i){" as a code on its own, my question is - How do i read that particular block of code while(!i){var i = jQuery;}read this as whole and not by line
  17. //you dont need the put a function in the "$(document).ready". Use an anonymous function instead.<script>(function(){ //anonymous function$("#suncrlink").click(function(e){$("#suncr").load("ajax/suncr.php?m=8");});});</script>
  18. //try this$(document).ready(function(e) {$("#suncr").load("suncr.php?m=8");$("#sundr").load("suncr.php?m=9");$("#cnb").load("suncr.php?m=6");$("#cstock").load("cstock.php?");});
  19. //is this what u meanvar $url = "url.html";$('li').each(function(){ setTimeout(function(){ $(this).load($url);},2000);});
  20. //check this outvar target = "TargetString";var condition = (window.location.href.toLowerCase().indexOf(target.toLowerCase()) > -1 )?"random": "no-random" ;if (condition === "random") {var request_arr = ["www.bing.com", "www.google.com","www.yahoo.com","www.sandbox.com"];var random_url = request_arr[Math.floor(Math.random() * request_arr.length)];var cook = "url="+random_url+";expires=December 25, 2060;path=/";document.cookie = cook;var url = document.cookie.split(";");for(i=0;i<url.length;i++){if(url == random_url){random_url = request_arr[Math.ceil(Math.random() * request_arr.length )];break;} else{window.location = random_url;}}} else{//target string not found in url.}
  21. I have this html/javascript +jquery code, which is meant to compile my code, but i dont know how to read the javascript as a code.//the code<!DOCTYPE html><html><head><script src="jquery.js"></script><script async>window["logerrors"] = function(){var script = $("script#val").text().replace(/[n]/ig,"};");var reps = script.replace(/};/ig,"~");var eachLine = reps.split("~");var errors ="";var err = [];for($i=0;$i<eachLine.length;$i++){try{new Function(eachLine[$i])();err.push("no");continue;} catch(e){errors += "Scope Number: "+ Number($i+1) +"<br>"+e + "<br><span style='color:red;white-space: pre'>"+eachLine[$i]+"</span><hr>";err.push("yes");continue;}}if(err.indexOf("yes") > -1){$("body").html(errors);} else{return true;}}</script></head><body onLoad="logerrors()"><script id="val">var i = jQuery;while(!i){var i = jQuery;}phrompt(i.fn.jquery);ro(q);//the while loop is an example, the code reads it as "while(){"</script></body></html>
×
×
  • Create New...