how to create a jquery toggle using existing html

2019-09-30 07:46发布

问题:

<div class="rsvp">
     <div class="block">

        <span class="rsvpNote">
        <h4 class="rsvpTitle">
            <a href="#" class="blockExpand" click="toggleRSVP(this); return false;"><span class="arrow"></span>RSVP</a>
        </h4> </div>

    </div>
</div>

Hello I have this code to work with and I need to make a toggle with Jquery however, I cannot make it work. Also, is there a way to customize the button that will make up this toggle. Content will follow underneath these DIV. Thanks.

回答1:

HTML:

<input type="button" value="click me" id="click">
    <div id="info">This is what you are expecting or may not , but im doing this just for fun</div>

Jquery:

$("#click").click(function () {
      $("#info").toggle('slow');
    });

CSS:

#info{
    width:200px;
    background-color:#9494B8;
    border-radius:3px;
    padding:5px;
    display:none;
}

See the DEMO