Why “1.0” is not equal to “+1.0” in JavaScript?

I am doing a simple comparison in JavaScript but its not working. Here is the script var value = ‘1.0’; var minLimit = ‘+0.5’; var maxLimit = ‘+999’; if (value >= minLimit && value <= maxLimit) { console.log(value); } else { console.log(‘not matched’); } Is there anything I am missing comparison ? Here is the […]

How can I automatically refresh my site while editing the CSS?

I am working on HTML/CSS/JavaScript from within emacs. My workflow is currently Make a change -> Alt-Tab to browser -> F5 (refresh) -> Alt Tab to emacs Do any extensions exist that would auto-refresh the browser on a change? Or, possibly a better idea, when I hit a key combination from within emacs?

In my “if/else” statement my “else” statement isn't working

I am very new to coding (using codeacademy to learn Javascript) and I need a little help with this mini project I’m working on. I am trying to make the computer randomly choose either a boy name or girl name from two different arrays. I used an if/else statement to make the computer choose between […]

JavaScript – Passing Arguments to Anonymous Functions

I’m calling an anonymous function: closeSidebar(function() { alert(“function called”); $(this).addClass(“current”); setTimeout(function(){openSidebar()}, 300); }); But $(this) doesn’t work as expected and I need to pass it as an argument into the function. After a bit of research I thought this would work: closeSidebar(function(el) { $(el).addClass(“current”); setTimeout(function(){openSidebar()}, 300); })(this); But it doesn’t. How do I add arguments […]

HTML / Javascript: On Click Enable/UnDisable Input Fields?

I have the following HTML input boxes: <form> <input type=”text” name=”1″ id=”1″ disabled> <input type=”text” name=”2″ id=”2″ disabled> <input type=”text” name=”3″ id=”3″ disabled> <input type=”text” name=”4″ id=”4″ disabled> <input type=”submit” name=”submit” value=”submit> </form> Next I am trying to use javascript to undisable all my input boxes upon a user clicking my div. JavaScript: <script> $(‘#edit’).click(function(){ […]

Javascript TIFF Image Conversion

I am looking for a way to convert a Tiff image into a png so modern browsers can render it. I have looked at Tiffus, but that doesn’t look like it is being developed anymore. I have also tried writing a conversion program in C# and sending through JSIL, but that didn’t work either. I […]

How should I setup circular refs in JavaScript

I have a small little problem in JavaScript. I would like to do the following: var peter = { pet : spot } var spot = { owner : peter } The above code runs fine but peter.pet will be undefined. While spot.owner will be defined. IS there a better way then doing stuff like […]

Wait until all ajax requests are done

I need to wait until all my ajax functions are done, and then continue the exectution. My particular case is that I need to translate some fields in a form before submitting it. I translate them with an ajax call to an external site. Depending on some values in the form i would need to […]

JavaScript draw a circle on mouse click – cordinates don't match

I’m writing a simple script where the user clicks anywhere in a canvas and there appears a circle. The script works but not correct. Somehow the cordinates where the click event happens and the circle center don’t match. Any ideas why? Here is the code : <html> <head> <script type=”text/javascript” src=”http://code.jquery.com/jquery-latest.js”></script> <script type=”text/javascript”> jQuery(document).ready(function(){ $(“#special”).click(function(e){ […]

How to make canvas element in html clickable?

I am designing a web page which has a lot of mathematical figures .e.g rhombus ,square ,rectangle,triangle etc…. what I am trying to achieve is ,when I click on any of the figures ,it should show up a msg /info kind of thing. I have only one canvas id ,and lot of figures in it […]