Skip to content
Advertisement

Why does this regex replace remove a symbol at the start, but not at the end?

I am trying to remove the apostrophes from this string: “‘234324234234234236548723adf83287942′”. I am trying to use this: to try and get “234324234234234236548723adf83287942”. But I can’t seem to crack it. How do I remove the apostrophes (‘)? Answer Just use ‘ on it’s own with the global modifier: Alternatively, if the quotes are always at the start and end, you don’t

Getting timestamp from mongodb id

How do I get the timestamp from the MongoDB id? Answer The timestamp is contained in the first 4 bytes of a mongoDB id (see: http://www.mongodb.org/display/DOCS/Object+IDs). So your timestamp is: and

How to capture the text of an Select option?

So I have this: How would I go about grabbing the ‘text’ of the options here? The problem is, it needs to be ‘dynamic’, in the sense I need the text for the currently selected option… I know a manual, static way of getting the text… That will grab “This is You”… But how do I get it for the

Track mouse speed with JS

What’s the best way to track the mouse speed with plain JS/JQuery? I’d like to track how fast a user moves the mouse in all directions (up/down/left/right). Answer Sparklines has a nifty example of tracking mouse movement and graphing it. Their code is available in the source of their site starting at line 315. Simple and effective. Here is the

document.getElementByID is not a function

I’m learning jQuery and was following a tutorial, a very strange error has perplexed me. Here’s my html : and The jQuery : When I add elements By hitting the return key, there’s no problem. But When I click the Submit Button then firebug shows this error I tried to use jQuery instead replacing it with This time the error

Unlimited arguments in a JavaScript function

Can a JavaScript function take unlimited arguments? Something like this: I am trying: But this doesn’t work (output is only the first argument). Or the only way is: Thanks Answer There’s a weird “magic” variable you can reference called “arguments”: It’s like an array, but it’s not an array. In fact it’s so weird that you really shouldn’t use it

Backbone View events not firing

I am using Rails3 as my backend and Jammit to asset… Now I am trying to not compress and even package the assets. The simple event don’t get run, but the alert(‘asd’) int initialize is working as expected. I have already tried other kinds of events in other objects too, but it didn’t work. My code as follow: and my

Validating css color names

I’ve written a jQuery plugin that accepts css colors for some of its parameters. I want to validate them. If it was just a hex or rgb value I could do that with a regular expression, but how do I validate all 147 valid color names without bloating the plugin? I was wondering if there is some way of attempting

Image Enlarger Script

I am looking for one of those scripts that when you click a Thumbnail, it makes the picture englarge. I tried searching Google using a lot of terms, but cant find any. Where do I get these? Answer I believe one of these are what you are looking for. http://leandrovieira.com/projects/jquery/lightbox/ http://jquery.com/demo/thickbox/

Advertisement