Check if one list contains element from the other

If you just need to test basic equality, this can be done with the basic JDK without modifying the input lists in the one line !Collections.disjoint(list1, list2); If you need to test a specific property, that’s harder. I would recommend, by default, list1.stream() .map(Object1::getProperty) .anyMatch( list2.stream() .map(Object2::getProperty) .collect(toSet()) ::contains) …which collects the distinct values in … Read more

How to get asp.net client id at external javascript file

I can suggest 2 ways. First way define your variables before call the javascript, inside the .aspx file that can be compiled. var ButtonXXXID = <%=buttonXXX.ClientID%> // and now include your javascript and use the variable ButtonXXXID Second way in the external javascript file, write your code as: function oNameCls(ControlId1) { this.ControlId1 = ControlId1; this.DoYourWork1 … Read more

How to appendChild(element) many times. (The same element)

appendChild will remove the node from wherever it is before appending it to its new location, so you need to make copies of the node instead. You can use cloneNode for that. The true makes cloneNode perform a deep clone, i.e. with all its child nodes. for(var i = 0; i < urls.length; i++){ sliderBody.appendChild(slide.cloneNode(true)); … Read more

Checking if array is multidimensional or not?

Use count() twice; one time in default mode and one time in recursive mode. If the values match, the array is not multidimensional, as a multidimensional array would have a higher recursive count. if (count($array) == count($array, COUNT_RECURSIVE)) { echo ‘array is not multidimensional’; } else { echo ‘array is multidimensional’; } This option second … Read more

Can I use document.getElementById() with multiple ids?

document.getElementById() only supports one name at a time and only returns a single node not an array of nodes. You have several different options: You could implement your own function that takes multiple ids and returns multiple elements. You could use document.querySelectorAll() that allows you to specify multiple ids in a CSS selector string . … Read more

Get the string representation of a DOM node

You can create a temporary parent node, and get the innerHTML content of it: var el = document.createElement(“p”); el.appendChild(document.createTextNode(“Test”)); var tmp = document.createElement(“div”); tmp.appendChild(el); console.log(tmp.innerHTML); // <p>Test</p> EDIT: Please see answer below about outerHTML. el.outerHTML should be all that is needed.

tech