Skip to content

Href=”#” Don’t Scroll

I am pretty new to JS – so just wondering whether you know how to solve this problem. Current I have in my code Which runs some JS to close a box. The problem I have is that when the user clicks on the link – the href=”#” takes the user to the top of page when this happens. How

How to run two jQuery animations simultaneously?

Is it possible to run two animations on two different elements simultaneously? I need the opposite of this question Jquery queueing animations. I need to do something like this… $(‘#first’)….

How to get a JavaScript object’s class?

I created a JavaScript object, but how I can determine the class of that object? I want something similar to Java’s .getClass() method. Answer There’s no exact counterpart to Java’s getClass() in JavaScript. Mostly that’s due to JavaScript being a prototype-based language, as opposed t…

Disable pasting text into HTML form

Is there a way using JavaScript to disable the ability to paste text into a text field on an HTML form? E.g. I have a simple registration form where the user is required to input their email twice. The second email entry is to verify there are no typos in the first email entry. However if the user copy/pastes…

Close all popup windows with Javascript

Does anyone know how can I close all popup windows (window popup by javascript) in Javascript? Example: Open 3 new windows by clicked on a button, and using window.open() to open all 3 new windows. Clicked on a button and close all 3 popup windows togather. Answer Second result on Google. Closes ALL Windows a…

Smart way to truncate long strings

Does anyone have a more sophisticated solution/library for truncating strings with JavaScript and putting an ellipsis on the end, than the obvious one: Answer Essentially, you check the length of the given string. If it’s longer than a given length n, clip it to length n (substr or slice) and add html e…

Execute Background Task In Javascript

I have a cpu intensive task that I need to run on the client. Ideally, I’d like to be able to invoke the function and trigger progress events using jquery so I can update the UI. I know javascript does not support threading, but I’ve seen a few promising articles trying to mimic threading using se…