如何使用jQuery显示新内容

How to show new content using jQuery

本文关键字:新内容 显示 jQuery 何使用      更新时间:2024-04-07

基本上这就是CODE但由于某些原因,它不会显示新的内容,如果有人能帮助我,我将不胜感激。

我希望能够在点击按钮后显示新内容,请看完整的代码

html

<section class="showr">
    <a rel="external" href="#button" id="button" class="button">&#xF011;</a>
    <span></span>
</section>
<p class="hidn"> Welcome To a Crazy World</p>`

jquery

$(document).ready(function(){
    $('#button').click(function(){
        $(this).toggleClass('on');
    });
});

$('#button').click(function(){ ... });中的所有内容都是在单击按钮时执行的,因此您需要在显示其他元素的函数中添加代码。

$(document).ready(function(){
    $('#button').click(function(){
        $(this).toggleClass('on');
        $('p.hidn').show();
    });
});

但也许你的意思是你想切换内容?

$('p').toggleClass('hidn');

注意,这将影响页面上的其他段落。您可能希望为内容提供一个ID并将其作为目标。