Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

removing a DOM object from an array of DOM

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!

like image 308
Chinchan Zu Avatar asked Nov 24 '25 10:11

Chinchan Zu


1 Answers

.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()
like image 184
Felix Kling Avatar answered Nov 25 '25 23:11

Felix Kling



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!