单击时更改每个 <td> 的 .html

Changing the .html of each <td> on click

这是我第一次尝试从头开始使用 this,我不确定我是否理解正确。我正在尝试将其中包含 +<td> 更改为单击时的 -,反之亦然。 我没有收到任何错误,也不确定我做错了什么。单击时没有任何反应。我在页面上还有其他 jquery 工作正常。

echo "<script type'text/javascript'>
$('.plus_minus').each(function() {
    $(this).click(function(){
        if ($(this).html() == '+'){
            $(this).html = '-';
        }
        else {
            $(this).html = '+';
        }

    })
 });

</script>";

html看起来像

echo '<tr align="right" class="loc"><td class="plus_minus" width="20" align="center" 
            bordercolor="#000000"
            style="cursor:pointer;font-size:10pt;font-weight:bold;
            border-style:solid;border-width:1pt">+</td>';

如有任何帮助,我们将不胜感激!

$('.plus_minus').each(function() {
   $(this).click(function(){
        if ($(this).text() == '+'){
            $(this).text('-');
        }
        else {
            $(this).text('+');
        }

   })
 });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr align="right" class="loc"><td class="plus_minus" width="20" align="center" 
            bordercolor="#000000"
            style="cursor:pointer;font-size:10pt;font-weight:bold;
            border-style:solid;border-width:1pt">+</td>
</tr>
</table>