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 6601901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:48:46+00:00 2026-05-25T18:48:46+00:00

In my mobile app, using jQuery Mobile… I would like to make a simple

  • 0

In my mobile app, using jQuery Mobile…

  • I would like to make a simple button execute a simple javascript function on click. No page transitions, nothing special like that.

  • I understood I can eliminate the page transitions by doing return false or preventDefault()

  • But the problem is the button sticks with the “active” state, i.e. highlighted blue if you use the general theme. I’m wondering how I can remove that after click (or tap, etc).

Thanks.

  • 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-05-25T18:48:46+00:00Added an answer on May 25, 2026 at 6:48 pm

    Update:

    This question and the hacks suggested are now a bit outdated. jQuery mobile handles buttons quite a bit differently than 3 years ago and also, jQuery mobile now has several different definitions of “button”. If you want to do what the OP was looking for, you might now be able to avoid the issue by using this:

    Step 1:

    <button class="ui-btn myButton">Button</button>
    

    Alternatively, you could also use jQuery mobile input buttons:

    <form>
        <input value="Button One" type="button" class="myButton">
        <input value="Button Two" type="button" class="myButton2">
    </form>
    

    Step 2:
    Then your standard jquery on callback:

    $(".myButton").on("tap", function(e) {
        // do your thing
    });
    

    If you are using a button or a tab, or whatever, that has the “active” class applied to it (the default is ui-btn-active), the old answer may still be useful to someone. Also, here is a fiddle demonstrating the code below.


    Selectively removing active state:

    As demonstrated in another answer, you can disable the active state for all buttons on all pages. If that is acceptable for the project in question, that is the appropriate (and simpler) solution. However, if you want to disable the active state for some buttons while preserving active states for others, you can use this method.

    Step 1:

        $(document).bind('mobileinit', function() {
            $(document).on('tap', function(e) {
                $('.activeOnce').removeClass($.mobile.activeBtnClass);
            });
        });
    

    Step 2:

    Then add the activeOnce class (or whatever you want to call it – it’s a custom class) to the buttons that you don’t want to highlight when clicking.

    And as is usual when binding anything to mobileinit, be sure you place your bindings – and perhaps better, all your javascript code – below the jQuery script and above the jQuery-mobile script.

    <script src="js/jquery.js"></script>
    <script src="js/my_script.js"></script>
    <script src="js/jquery.mobile.js"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a mobile app using jQuery Mobile and I would like to
I'm building a mobile app using HTML, CSS, Javascript and jQuery. Is there a
I'm working on a simple web app using jQuery mobile, and it is designed
I am working on a simple web app using jquery mobile. I am attempting
I am developing a mobile app using HTML5, Javascript, jQuery Mobile, and offline storage.
I have a mobile app created using HTML/JS(jQuery)/CSS and I'm looking to include page
I've implemented a simple app using a listview From jQuery-mobile, it appears as hyperlink
I'm using jQTouch to build a simple mobile app with an html/js/jquery form that
I am working on an iPhone mobile web app using jqtouch to make it
I have created app using jQuery Mobile and need to get a Dialog box

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.