Skip to content
Advertisement

Tag: javascript

What’s the difference between JavaScript and JScript?

I have always wondered WHaT tHE HecK?!? is the difference between JScript and JavaScript. Answer Just different names for what is really ECMAScript. John Resig has a good explanation. Here’s the full version breakdown: IE 6-7 support JScript 5 (which is equivalent to ECMAScript 3, JavaScript 1.5) IE 8 supports JScript 6 (which is equivalent to ECMAScript 3, JavaScript 1.5

Highlight a word with jQuery

I basically need to highlight a particular word in a block of text. For example, pretend I wanted to highlight the word “dolor” in this text: How do I convert the above to something like this: Is this possible with jQuery? Edit: As Sebastian pointed out, this is quite possible without jQuery – but I was hoping there might be

How to create query parameters in Javascript?

Is there any way to create the query parameters for doing a GET request in JavaScript? Just like in Python you have urllib.urlencode(), which takes in a dictionary (or list of two tuples) and creates a string like ‘var1=value1&var2=value2’. Answer Here you go: Usage:

Best Javascript drop-down menu? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

How to show a spinner while loading an image via JavaScript

I’m currently working on a web application which has a page which displays a single chart (a .png image). On another part of this page there are a set of links which, when clicked, the entire page reloads and looks exactly the same as before except for the chart in the middle of the page. What I want to do

Getting the ID of the element that fired an event

Is there any way to get the ID of the element that fires an event? I’m thinking something like: Except of course that the var test should contain the id “aaa”, if the event is fired from the first form, and “bbb”, if the event is fired from the second form. Answer In jQuery event.target always refers to the element

How do you remove all the options of a select box and then add one option and select it with jQuery?

Using core jQuery, how do you remove all the options of a select box, then add one option and select it? My select box is the following. EDIT: The following code was helpful with chaining. However, (in Internet Explorer) .val(‘whatever’) did not select the option that was added. (I did use the same ‘value’ in both .append and .val.) EDIT: Trying

Why doesn’t JavaScript support multithreading?

Is it a deliberate design decision or a problem with our current day browsers which will be rectified in the coming versions? Answer JavaScript does not support multi-threading because the JavaScript interpreter in the browser is a single thread (AFAIK). Even Google Chrome will not let a single web page’s JavaScript run concurrently because this would cause massive concurrency issues

Is there an “exists” function for jQuery?

How can I check the existence of an element in jQuery? The current code that I have is this: Is there a more elegant way to approach this? Perhaps a plugin or a function? Answer In JavaScript, everything is ‘truthy’ or ‘falsy’, and for numbers 0 means false, everything else true. So you could write: You don’t need that >0

Advertisement