Reputation: 3343
This is kind of silly and newbie question though,
How would you use jQuery for current page of Jquery mobile which is actually just a Div
element in the whole html file.
I am currently using $("#" + $.mobile.activePage.attr("id"))
to select the current page though,is there any better way to do the same?
InAddition I'd be glad if you suggest the way to select its footer/header elements directly.
Thanks for your answer.
Upvotes: 0
Views: 82
Reputation: 31732
jQuery Mobile <= 1.3
Use $.mobile.activePage
which returns a DOM collection.
var activePage = $.mobile.activePage,
activePageID = activePage[0].id,
header = $(".ui-header", activePage), /* or [data-role=header] */
footer = $(".ui-footer", activePage); /* or [data-role=footer] */
jQuery Mobile >= 1.4
Use $.mobile.pageContainer.pagecontainer("getActivePage")
.
var activePage = $.mobile.pageContainer.pagecontainer("getActivePage"),
activePageID = activePage[0].id,
header = $(".ui-header", activePage), /* or [data-role=header] */
footer = $(".ui-footer", activePage); /* or [data-role=footer] */
Upvotes: 1
Reputation: 61
$('.ui-page-active').attr('id')
will do the same for selecting current page in jqueymobile
Upvotes: 0