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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:04:10+00:00 2026-06-17T11:04:10+00:00

I would like to have a button that changes data-icon class depending upon user

  • 0

I would like to have a button that changes data-icon class depending upon user selections

Example button would be:

<a href="#language2" data-rel="popup" data-role="button" 
                     data-icon="english-flag" data-inline="true" 
                     data-position-to="origin">
    <span id="language3">English</span>
</a>

I’d like to know what javascript code I would need to implement in order to change the custom defined data-icon="english-flag" to be instead data-icon="another-flag"

Thanks in advance.

Edit: The answer to my followup questions below on how to specify which button to affect can be found at;
How to change a specific JQuery Mobile button icon with javascript

  • 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-17T11:04:11+00:00Added an answer on June 17, 2026 at 11:04 am

    jQuery Mobile has a predefined function:

    $('a').buttonMarkup({ icon: "star" });
    

    It is not enough to change an attribute, final button restyling must be done with .buttonMarkup( function.

    Here’s an official documentation: http://jquerymobile.com/demos/1.2.0/docs/buttons/buttons-options.html

    And here’s an example: http://jsfiddle.net/Gajotres/AmFKa/

    Also, because you are creating a custom button it wont be enough just to change icon name, first you need to define it in your css like this:

    <style type="text/css">
        .ui-icon-edit {
           background-image: url(icons-18-white.png); // This should be your picture
           background-repeat: no-repeat;
           background-position: -824px 50%;
        }
    </style>
    

    We would add this new icon like this:

    $('a').buttonMarkup({ icon: "edit" });
    

    In this case we are adding picture edit. Now notice its cass name .ui-icon-edit, to add a new icon class you need to combine a .ui-icon- string with a icon name. In your case your class name would be .ui-icon-another-flag.

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

Sidebar

Related Questions

I would like to have a button in my window such that if I
Ok, let's say that I have a button and I would like to enable/disable
I would like to have more than one button. I tried to copy code
In Interface Builder components I have Gradient Button I would like to create this
I have a button which creates a div. Once clicked I would like to
I have a mvc3 Ajax.BeginForm. Instead of clicking on the button I would like
So in my project i would like have a nice treeview that has images.
I would like to have an AppWidget that designed like this one . Image:
I have data being imported from a database and I would like to represent
I would like to have a user redirected to an external credit card gate.

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.