Jquery html() inside conditional check

these are extract of my code

<button>Hook It!</button>

and a bit of JQuery

$("ul li .tag_detail button").on('click', function() {
    if ($(this).html() == 'Hook It!') {
    if ($(this).html() == 'Unhook!') {
        $(this).html('Hook It!');

Now, as you can see i want a toggling effect, i.e. when i click on button it should toggle between Hook It! and Unhook!.

The problem lies here

if($(this).html() == 'Hook It!')

here this condition never passes while console log prints Hook It!


40 thoughts on “Jquery html() inside conditional check”

Leave a Comment