removing a DOM object from an array of DOM

dom, javascript, jquery, jquery-mobile

Solution

`.remove()` is a jQuery method, so you need a jQuery object to call it on. `.get` returns a DOM element though. Use `.eq` [docs] instead to get the element as jQuery object:

$("div:jqmData(role='page')").eq(0).remove()

Problem

if i use this `$("div:jqmData(role='page')")` it will return me the array of pages in my `DOM` object. But jquerymobile creates a default blank page which doesnt have any ID so i cant actually get it by its ID. instead i use `$("div:jqmData(role='page')").get(0)` to get the first DOM object representing the default Page jquery created. but if i use `$("div:jqmData(role='page')").get(0).remove()` it doesnt remove the page, but it returns errors. can anyone teach me on how to remove that DOM? thanks!

Original source