I want to check if $('#td1').text() === “x”?

后端 未结 5 1398
余生分开走
余生分开走 2021-01-28 16:10

I want to check if innerHtml have X or O , so i can not add again any thing else , but it\'s not working . it stop after adding the check code , I\'m trying here to do a simple

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-28 16:46

    You don't have to check both if the text is equal to x or not equal to o, one makes the other superflous.

    When you set the text of an element using jQUery you supply the value in the call to text, you don't assign it to the return value of the function.

    I assume that you want to use the c parameter when you check the value also.

    function tdElm(c) {
      if ($('#td' + c).text() == "o") {
        $('#td' + c).text("x");
      }
    }
    

提交回复
热议问题