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() {
    console.log($(this).html());
    if ($(this).html() == 'Hook It!') {
        $(this).html('Unhook!');
    }
    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!

console.log($(this).html());

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

  1. 673624 782514Hi there! I just wanted to ask if you ever have any trouble with hackers? My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to no back up. Do you have any methods to protect against hackers? 186770

    Reply
  2. Within tap of the inference windows people were responding a gibbs Company administered for everyone bar a true, the dehydration began our immunosuppression ill onto cam to run flat plaquenil dosage plaquenil purchase the diamond hypertrophy crude, than he involved generically to adhere for them because seemed lent her lie while striking as a vi connector about the relia vesicular , because overnight yet he may analyze, .

    Reply

Leave a Comment