简体   繁体   中英

Using JavaScript to Trigger Div on Page w/ Certain Body Class On Button Click

Let's say I have a page with:

<body class="Test">

And I have a button on the page as follows:

<div id="FinishButton">

And then I have a div on the page as below:

<div class="slide-1">

And then I have a hidden div as follows:

<div class="slide-2">

How can I use JavaScript to make slide-2 appear and slide-1 disappear when I click that button ONLY on a page with the body class of "Test"?

Thanks!

    $('.Test'>'#FinishButton').click(function(){
        $('.slide-1').hide();
        $('.slide-2').show();
    })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM