How to write an element just after another with javascript? [duplicate]

The accepted answer will work in this specific case, but to insert an element after another more generally, the following does the job: someElement.parentNode.insertBefore(newElement, someElement.nextSibling); Where newElement is the element to be inserted and someElement is the element it is to be inserted after. W3C insertBefore method of the Node interface

pass element ref to a method in angular2

Simply do : Template Side : <div #refEl (click)=’yourFunc(refEl)’> Component Side : yourFunc(el: HTMLElement){ console.log(el); // you can check the output in the console } ———————— OR ————————– Template Side : <div (click)=’yourFunc($event.target)’></div> Component Side (Same as above): WORKING DEMO

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element:

Looks like it takes time to load the webpage, and hence the detection of webelement wasn’t happening. You can either use @shri’s code above or just add these two statements just below the code driver = webdriver.Firefox(): driver.maximize_window() # For maximizing window driver.implicitly_wait(20) # gives an implicit wait for 20 seconds

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