Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7721043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:49:27+00:00 2026-06-01T03:49:27+00:00

I am trying to hide all the label tags on my jQuery Mobile site

  • 0

I am trying to hide all the label tags on my jQuery Mobile site in an accessibility friendly way. To this end, I am using javascript to apply the class ui-hidden-accessible to every label tag on my site per documentation (http://jquerymobile.com/test/docs/forms/docs-forms.html).

However, my javascript is not working.

Here is a Fiddle demonstrating how the label tag still appears.
http://jsfiddle.net/tW4Xu/

Why is it not working? I have also scrutinized other jQM event handlers such as pageinit and pagecreate:
http://jquerymobile.com/test/docs/api/events.html

My javascript to hide label tags:

// done after page is loaded
$(document).on("pageshow", "label", function(event) {
   $(this).addClass("ui-hidden-accessible");     
});​
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:49:29+00:00Added an answer on June 1, 2026 at 3:49 am

    It seems like you have a few things going wrong here, although I’m not sure how much of it is coming from the jsfiddle summary and how much is in your full code.

    The first thing to note is that ‘pageshow’ is a page transition event. It seems like you might want to use ‘pageinit’ instead. Here’s how the jQM docs describe it:

    Triggered on the page being initialized, after initialization occurs. We recommend binding to this event instead of DOM ready() because this will work regardless of whether the page is loaded directly or if the content is pulled into another page as part of the Ajax navigation system.

    $( '#aboutPage' ).live( 'pageinit',function(event){  
        alert( 'This page was just enhanced by jQuery Mobile!' );  
    });
    

    Note also here that 1) the event is being bound with live() instead of on() (no idea if there’s a difference), and 2) it is being attached to a specific id for a jQM ‘page’. This is part of what is missing in your jsfiddle example. There aren’t any named jQM pages. jQM kind of messes up the whole idea of a page being ready, since everything is in one html file and then gets chunked out using ids and inserted via AJAX.

    And so finally: Even though jQM says not to, if your goal is to add this class to every single label on every single jQM page, I would use good-old $(document).ready() and then use $.each() to change them all in one go. Again, from the jQM docs:

    However, in jQuery Mobile, Ajax is used to load the contents of each page into the DOM as you navigate, and the DOM ready handler only executes for the first page. To execute code whenever a new page is loaded and created, you can bind to the pageinit event.

    So there isn’t anything evil about $.ready(), it’s just that this event is only fired once so subsequent page transitions won’t trigger it. But that could be exactly what you want in the first place.

    This code works on jsfiddle:

    $(document).ready( function(event) {  
      $("label").each( function(index, element) {   
        element.addClass("ui-hidden-accessible");  
      });  
    });​
    

    If in your real site you notice that page transitions cause the labels to come back, then you’ll want to bind to something else, again probably ‘pageinit’.

    Hope this helps! Apologies for the verbosity…I kind of got going there huh?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to hide all the tags in html that are <input type=radio>
I'm trying to make a jQuery script that will hide all the visible elements
Trying to hide all others, but it keeps affecting the $(this) item. $(function() {
Hope you can help. Trying to hide all < li > tags greater than
What's wrong with this? I'm trying to hide all empty li. $(document).ready(function() { $(#details
I am trying to hide some <options> tags with jquery but it doesn't seem
I'm trying to hide table view until all the data is loaded. I found
I am trying to hide a div with an id #op-four using on instead
I am attempting to hide this checkbox, which is a check all checkbox in
I am trying to use javascript to display or hide a section of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.