Jump to content

kodejuice

Members
  • Posts

    23
  • Joined

  • Last visited

Posts posted by kodejuice

  1. 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>

    • Like 1
  2. Yes, you do. Javascript is no longer just a small scripting language to make flashy effects on a website, it's pretty much a full programming language in which you can make virtually anything. Applications such as Office365 and Google Docs are made in Javascript and there are entire videogames made with it these days. If you just want to make a few effects on your websites you don't have to learn algorithms and data structures, but if you actually want a job as a Javascript programmer for any company then you really need to know these.

    Thanks alot, please can you recommend any algorithm/data structures book for a javascript programmer.
  3. 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.

  4.  

    toggledFunctions = {};function toggleFunc(name, fn1, fn2){    if(toggledFunctions[name])   {       fn1.call(fn1);       toggledFunctions[name] = false;   }   else   {      fn2.call(fn2);      toggledFunctions[name] = true;   }} // toggleFunc('test1', func1, func2);
    Thanks a lot, fixed my problem
  5. 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.

  6. //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>

  7. //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.}

  8. 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...