How to remove all siblings in JavaScript? -


i have 4 images , want remove other 3 when clicked.

i 1 one with:

function removeimages() { var elem = document.getelementbyid('image1'); elem.parentnode.removechild(elem); } 

but not practical.

what best way remove siblings (images) except 1 clicked?

why don't try use jquery manipulate dom? easier , supported browsers. code follows:

$("#imgcontainer img").click(function () {     $(this).siblings().remove(); }); 

please have @ working version: js fiddle


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -