Skip to content
Advertisement

Tag: javascript

Check if a string has white space

I’m trying to check if a string has white space. I found this function but it doesn’t seem to be working: By the way, I added quotes to RegExp. Is there something wrong? Is there anything better that I can use? Hopefully JQuery. Answer You can simply use the indexOf method on the input string: Or you can use the

How to avoid scientific notation for large numbers in JavaScript?

JavaScript converts integers with more than 21 digits to scientific notation when used in a string context. I’m printing an integer as part of a URL. How can I prevent the conversion from happening? Answer There’s Number.toFixed, but it uses scientific notation if the number is >= 1e21 and has a maximum precision of 20. Other than that, you can

How to get a DOM Element from a jQuery selector?

I’m having an impossibly hard time finding out to get the actual DOMElement from a jQuery selector. Sample Code: and in another piece of code I’m trying to determine the checked value of the checkbox. And please, I do not want to do: That gets me around the checkbox, but other times I’ve needed the real DOMElement. Answer You can

fastest MD5 Implementation in JavaScript

There are many MD5 JavaScript implementations out there. Does anybody know which one is the most advanced, most bugfixed and fastest? I need it for this tool. Answer I’ve heard Joseph’s Myers implementation is quite fast. Additionally, he has a lengthy article on Javascript optimization describing what he learned while writing his implementation. It’s a good read for anyone interested

What is the ‘new’ keyword in JavaScript?

The new keyword in JavaScript can be quite confusing when it is first encountered, as people tend to think that JavaScript is not an object-oriented programming language. What is it? What problems does it solve? When is it appropriate and when not? Answer It does 5 things: It creates a new object. The type of this object is simply object.

e.which ENTER key enabled only if input field focus

I am using a e.which of jquery for running a function on press of ENTER, but I want this function to be called only if the particular input field is focused (where the cursor is blinking). My current jquery function. I want that $(“#search”).click(); to be called only if the #search_text is focused or has some input, because I have

Advertisement