0

class = '99999'の列を持つ行が1つしかないテーブルがあります(他の行には異なるクラスの列があり、このテーブルはdisplay:tableによって生成されるため、行のIDを設定する方法はありません) 。class='99999'の列を持つ行全体を削除しようとしています。パーツのように見えます:

$("td.99999").first().parent().remove();

動かない。

htmlは次のようになります。

<html>
<head>
<script type="text/javascript" src="/js/jquery-1.3.2/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        alert("I am here");
        $("td.99999").first().parent().remove();
    });
</script>
</head>

<table border="1">
    <tr >
        <th>category</th>
        <th>rank</th>
        <th>priority</th>
        <th>contact</th>
        <th>price</th>
        <th>tax</th>
        <th>total price</th>
        <th>shipping</th>
        <th>Net payment</th>
    </tr>
    <tr class="displaytagOddRow">
        <td class="99999">category 1</td>
        <td class="99999">99999</td>
        <td class="99999">something</td>
        <td class="99999">something</td>
        <td class="99999 alignRight">$3,433</td>
        <td class="99999 alignRight">$300</td>
        <td class="99999 alignRight">$3,733</td>
        <td class="99999 alignRight">$349</td>
        <td class="99999 alignRight">$4,082</td>
    </tr>
    <tr class="displaytagOddRow">
        <td class="3333">category 2</td>
        <td class="3333">3333</td>
        <td class="3333">something</td>
        <td class="3333">something</td>
        <td class="3333 alignRight">$3,433</td>
        <td class="3333 alignRight">$300</td>
        <td class="3333 alignRight">$3,733</td>
        <td class="3333 alignRight">$349</td>
        <td class="3333 alignRight">$4,082</td>
    </tr>
</table>
</html>

私は何が間違っているのですか?

4

1 に答える 1

1

スクリプトタグとコードを記述しているのと同じタグにjqueryファイルへの参照を追加しました。次のように、別のスクリプトタグに配置する必要があります。

     <script type="text/javascript">
           $(document).ready(function(){

                                         alert("I am here");
                 $("td.99999").first().parent().remove();


                                      });
     </script>

以下のコードを次のように保持します

   <script type="text/javascript" src="/js/jquery-1.3.2/jquery-1.3.2.min.js"></script>

それはうまくいくでしょう...

于 2012-12-10T19:09:49.917 に答える