jquery .click being called multiple times

前端 未结 8 2247
小蘑菇
小蘑菇 2021-02-20 11:12

I am getting unexpected results with jQuery trying to set the \"click\" method of a div. Please see this jsfiddle. Be sure to open the console window. Click the word a few times

8条回答
  •  半阙折子戏
    2021-02-20 11:33

    The cleanest solution would be this: http://jsfiddle.net/kannix/fkMf9/4/

     $("#test").click(function() {
         $(this).text(($(this).text() == "Hello") ? "Goodbye" : "Hello");
     });
    

提交回复
热议问题