1

如何解决/更改折叠和展开状态标题中的文本颜色?谢谢!

4

1 回答 1

0

您可以在事件collapse中手动更改折叠/展开标题的颜色:expand

$("#mycollapsible").bind('expand', function() {

    // Change color here

}).bind('collapse', function() {

    // Change color here

});

#mycollapsible您的可折叠集的 ID在哪里。


完整的工作示例:

<!DOCTYPE html>
<html>
<head>

<meta name="viewport" content="width=device-width, initial-scale=1">   

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script> 

<script>

function toggle_color() {
    $("#mycollapsible .ui-icon-arrow-r").parent().find(".ui-btn-text").css('color', "red");
    $("#mycollapsible .ui-icon-arrow-l").parent().find(".ui-btn-text").css('color', "blue");
}

$(function() {

    // Initialization
    toggle_color();

    // Binding collapse / expand event
    $("#mycollapsible").bind('expand', function() {
        toggle_color();
    }).bind('collapse', function() {
        toggle_color();
    });
});

</script>
</head>


<body>
<div data-role="page">
  <div data-role="header">
    <h1>My Title</h1>
  </div>
  <!-- /header -->

  <div data-role="content">
    <p>Hello world</p>

    <div id="mycollapsible" data-role="collapsible-set" data-iconpos="right" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-l">
      <div data-role="collapsible" data-collapsed="true" >
        <h3>Section 1</h3>
        <p>I'm the collapsible set content for section 1.</p>
      </div>
      <div data-role="collapsible" data-collapsed="true">
        <h3>Section 2</h3>
        <p>I'm the collapsible set content for section 2.</p>
      </div>
    </div>


  </div>
  <!-- /content --> 

</div>
<!-- /page -->

</body>

</html>

希望这可以帮助 ;)

于 2012-10-13T21:45:18.617 回答