Site logo

Archived topic

A Strange Question

1 reply · Started by Joezer on February 16, 2020

Viewing posts 1–2 of 2

Hello,

I don't think this has been asked before but how do you do the "Are you happy with our support? Yes No". It's brilliant. I think I can use it to hide my social media buttons. Always to put those buttons but no matter which plugin I use, it always looks ugly. I think it can also be nice to implement it somewhere inside the article and ask a question to the reader in the middle of the article and whichever they answer, they will be pointed to a link. :)

Hi there,

It's some pretty simple HTML and jQuery.

For example, the HTML:

<div class="review-container">
    <p>
        Are you happy with our support? <span class="happy">Yes</span>&nbsp;&nbsp;<span class="unhappy">No</span>
    </p>

    <div class="happy" style="display: none;">
        <p>Great to hear!</p>
    </div>

    <div class="unhappy" style="display: none;">
        <p>Sorry to hear that!</p>
    </div>
</div>

And the jQuery:

$( '.review-container span.happy' ).on( 'click', function() {
    var _this = $( this );

    _this.closest( 'p' ).hide();
    _this.closest( '.review-container' ).find( 'div.happy' ).show();
} );

$( '.review-container span.unhappy' ).on( 'click', function() {
    var _this = $( this );

    _this.closest( 'p' ).hide();
    _this.closest( '.review-container' ).find( 'div.unhappy' ).show();
} );

There are other ways to do it as well if you Google "jQuery show hide toggle" :)

This archived topic is closed to new replies.