【问题标题】:How do I edit the text of a button when the content is displayed/actively showing?如何在显示/主动显示内容时编辑按钮的文本?
【发布时间】:2022-11-30 12:17:30
【问题描述】:

使用这个例子:http://jsfiddle.net/json/8cu34y4L/

<button data-switch="#about_me">Click to read about me</button>
<button data-switch="#education">Click to show my education</button>
<button data-switch="#about_name_bravitus">Click to read about the name Bravitus</button>

<div id="page-2">

    <div id="about_me" class="container">
         <h1>This is about me section</h1>

        <div>about me about me about me</div>
    </div>

    <!-- Hidden blocks that you show when requested. -->
    <div id="education" class="container" style="display: none;">
         <h1>This is about my education</h1>

        <div>education education education</div>
    </div>

    <div id="about_name_bravitus" class="container" style="display: none;">
         <h1>This is about the name bravitus</h1>

        <div>bravitus bravitus bravitus</div>
    </div>
</div>

$('[data-switch]').on('click', function (e) {
    var $page = $('#page-2'),
        blockToShow = e.currentTarget.getAttribute('data-switch');

    // Hide all children.
    $page.children().hide();

    // And show the requested component.
    $page.children(blockToShow).show();
    
});

当显示内容时(不是基于单击按钮的时间),如何更改按钮文本的字体颜色和粗细?

我试图找到有类似要求的帖子,但我非常挣扎。任何方向将不胜感激。

【问题讨论】:

    标签: javascript html jquery css


    【解决方案1】:

    在我尝试回答之前,我想澄清一下。在显示内容时更改特征到底是什么意思,您希望这些特征看起来如何?

    你是说根据出现的文本,你希望相关按钮的字体是粗体吗?

    【讨论】:

      猜你喜欢
      • 2016-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多