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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:35:34+00:00 2026-06-13T00:35:34+00:00

When I dynamically change the h2 content of a collapsible list in jquery mobile

  • 0

When I dynamically change the h2 content of a collapsible list in jquery mobile 1.2 the h2 tag looses it’s formatting.

Calling listview(‘refresh’) does not seem to fix it.

Any ideas?

<div id="mylist" data-role="collapsible" data-theme="a" data-content-theme="a" data-mini="true" >
<h2>Choose...</h2>
<ul data-role="listview">
<li data-mini="true"><a href="#">Item 1</a></li>
<li data-mini="true"><a href="#">Item 2</a></li>
<li data-mini="true"><a href="#">Item 3</a></li>
</ul>
</div>

<script>
$("#mylist li").live( 'click',function(event){

$("#mylist h2").text($(this).text());
$("#mylist").listview('refresh');

});
</script>
  • 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-13T00:35:36+00:00Added an answer on June 13, 2026 at 12:35 am

    You are overwriting the HTML structure that jQuery Mobile creates for your collapsible widget. The HTML structure of the <h2> element you’re attempting to update looks like this after initialization from jQuery Mobile:

    <h2 class="ui-collapsible-heading ui-collapsible-heading-collapsed">
        <a href="#" class="ui-collapsible-heading-toggle ui-btn ui-mini ui-btn-icon-left ui-corner-top ui-corner-bottom ui-btn-up-a" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="span" data-icon="plus" data-iconpos="left" data-theme="a" data-mini="true">
            <span class="ui-btn-inner ui-corner-top ui-corner-bottom">
                <span class="ui-btn-text">
                    Choose...
                    <span class="ui-collapsible-heading-status"> click to expand contents</span>
                </span>
                <span class="ui-icon ui-icon-plus ui-icon-shadow">&nbsp;</span>
            </span>
        </a>
    </h2>
    

    So taking this HTML structure into consideration, your code should target the .ui-btn-text element within the <h2> element.

    For example:

    $(document).on('click', "#mylist li", function(event){
        $("#mylist h2 .ui-btn-text").text($(this).text());
    });​
    

    Here is a demo: http://jsfiddle.net/XDnGs/

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

Sidebar

Related Questions

I am using jQuery Mobile with jQuery Mobile Router , to dynamically change content
How do I dynamically change the height of a div. Why does this not
I have an iframe tag and I want to dynamically change it using jquery
I want to dynamically change content , by following code. localStorage.removeItem(some key); but current
I am developing a single web application that will dynamically change its content depending
I'm trying to dynamically change a backgroundcolor in a part of a listview, I
I'm trying to change content dynamically based on a JRadioButton selection... My simplified code
I have one main form, and i want to dynamically change it's content, via
How to dynamically change the content of a TextView from another part of the
How do I dynamically change the content of a data grid to select the

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.