What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-01 05:10:03
parent class and add element addclass
// html <div class="parentElm" id="addActive"></div> // js function toggleClass(){ // get the properties of an element var element = document.getElementById("addActive"); // check if the element have clas... Add solution -
Javascript 2021-10-01 03:25:03
js array delete specific element
var colors = ["red","blue","car","green"]; var carIndex = colors.indexOf("car");//get "car" index //remove car from the colors array colors.splice(carIndex, 1); // colors = ["red",&... Add solution -
Other 2021-09-30 21:20:03
indexOf in myltidimentionall array
/** * Index of Multidimensional Array * @param arr {!Array} - the input array * @param k {object} - the value to search * @return {Array} */ function getIndexOfK(arr, k) { for (var i = 0; i < arr.length; i++) { var index = arr[i].indexOf(k)... Add solution -
Javascript 2021-09-30 16:03:02
javascript node has parent with class
/** * If the element/node ('child') has the class 'classname' => return true * Else: call the function again with parent until parent with class is found or no parent is left */ function hasParentClass(child, classname){ if(child.className.... Add solution -
Javascript 2021-09-30 15:43:06
return elements of an array from another array javascript
var toBeFiltered = [1,2,3,4,5,6]; var elements = [6,3,2]; var filteredElements = toBeFiltered.filter( function(e) { return this.indexOf(e) >= 0; }, elements ); console.log(toBeFiltered); console.log(elements); console.log(filteredE... Add solution -
Javascript 2021-09-30 08:49:05
how to remove element from array in foreach javascript
var pre = document.getElementById('out'); function log(result) { pre.appendChild(document.createTextNode(result + '\n')); } var review = ['a', 'a', 'b', 'c', 'b', 'a', 'a'], index = review.indexOf('a'); while (index !== -1) { review.splice(index,... Add solution