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

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

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

google shop client API returns 400 bad request error while adding an item -