Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 4 months ago. Improve this question I ha…
Tag: javascript
Can you attach a handler function with arguments to an onclick event for a number of elements in a loop?
I am trying to set an onclick event for thumbnails that are dynamically populated from a database. I need to set the function to handle an argument, which is the id of the bigger picture the thumbnail represents. The code I have now sets all the thumbnails to point to #18. If you see in the for-loop, it is su…
Format a number as 2.5K if a thousand or more, otherwise 900
I need to show a currency value in the format of 1K of equal to one thousand, or 1.1K, 1.2K, 1.9K etc, if its not an even thousands, otherwise if under a thousand, display normal 500, 100, 250 etc, using JavaScript to format the number? Answer Sounds like this should work for you:
Does scrollIntoView work in all browsers?
Does scrollIntoView() work in all browsers? If not is there a jQuery alternative? Answer It is supported yes, but user experience is… bad. As @9bits pointed out, this has long been supported by all major browsers. Not to worry about that. The main problem is the way that it works. It simply jumps to a p…
Calling a .dll function from a html page that runs on chrome and firefox
I have a dll written in c++. now i need to call the functions in the dll from a html page. I have done this by calling the dll in vbscript (Activex) so that i can run the only in IE. Now i need to run this on Chrome as well as Firefox. What i have to do, whether i
Remove multiple elements from array in Javascript/jQuery
I have two arrays. The first array contains some values while the second array contains indices of the values which should be removed from the first array. For example: I want to remove the values present at indices 0,2,4 from valuesArr. I thought the native splice method might help so I came up with: But it …
CreateElement with id?
I’m trying to modify this code to also give this div item an ID, however I have not found anything on google, and idName does not work. I read something about append, however it seems pretty complicated for a task that seems pretty simple, so is there an alternative? Thanks 🙂 Answer You should use the .…
Cross-Origin XMLHttpRequest in chrome extensions
According to chrome extensions API cross-origin calls using XMLHttpRequest object should be allowed if permissions are set: An extension can talk to remote servers outside of its origin, as long as it first requests cross-origin permissions. I am closely following the Google tutorial, but the code below is gi…
How to get a value from the closest with a specific class name?
Im using Jeditable inside a table, to update a value. The table looks like this: I want to pass the value inside when i use AJAX to post a value, but im not sure how to get the value. Im using: which is returning null. How do i get the value? Answer You should do because closest() goes up the
Select Radio Button if a Dropdown is Selected
I’m wondering how I can use JavaScript to accomplish the following: I have an input area with five dropdownlists, and each one has a corresponding radio button. When a dropdownlist is clicked to make a selection, I would like the radio button paired with it to become checked right then. Any help would b…