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!
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!
Share Improve this question edited Aug 15, 2012 at 11:45 Vinay 6,8774 gold badges34 silver badges51 bronze badges asked Aug 15, 2012 at 11:41 Chinchan ZuChinchan Zu 9185 gold badges20 silver badges40 bronze badges 1- "it will return me the array of pages" - Correction: it will return a jQuery object with your pages. – nnnnnn Commented Aug 15, 2012 at 11:49
3 Answers
Reset to default 5.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()
The .get()
function returns the DOM element itself, so you won't be able to chain jQuery functions (such as .remove()
) after it. If you need to do that, use the .eq()
method which returns that single DOM element wrapped in a jQuery object, allowing you to chain.
It doesn't work because .get()
returns the underlying DOM element, not the jQuery object. You can use .eq()
to access the jQuery object at a specific index.
So this should work:
$("div:jqmData(role='page')").eq(0).remove()
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745220985a4617247.html
评论列表(0条)