I need a quick algorithm to select 5 random elements from a generic list. For example, I’d like to get 5 random elements from a List<string>. 32 Answers 32...
Say I have this: <div class="class1 class2"></div> How do I select this div element? document.getElementsByClassName('class1')[0].getElementsByClassName('class2')...
I’m brand new to jQuery and have some experience using Prototype. In Prototype, there is a method to “flash” an element — ie. briefly highlight it in another color...
In Javascript, I’m trying to take an initial array of number values and count the elements inside it. Ideally, the result would be two new arrays, the first specifying...
I need to choose some elements from the given list, knowing their index. Let say I would like to create a new list, which contains element with index 1,...
Is it possible, using jQuery, to find out the type of an element with jQuery? For example, is the element a div, span, select, or input? For example, if...
How can I reference the script element that loaded the javascript that is currently running? Here’s the situation. I have a “master” script being loaded high in the page,...
This question already has answers here: How to get names of enum entries? (41 answers) Closed 5 years ago. What is the proper way to loop through literals of...
Using jQuery, how can I get the input element that has the caret’s (cursor’s) focus? Or in other words, how to determine if an input has the caret’s focus?...
What I’m trying to do is to count all of the elements in the current page with the same class and then I’m going to use it to be...