$("tr").remove("#k45"); 
想要删除tr id 为k45标签但是k后面的45是通过 this.id 获取过来的。  我该怎么写?

解决方案 »

  1.   

    $("tr #k" + this.id).remove();  
      

  2.   


    removeTr=function(txt){
    $(txt).parent().parent().remove();
    }<table>
      <tr>
         <td><input type="button" onclick="removeTr(this)" /></td>
      </tr>
    </table>
      

  3.   


    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    <script>
    $(function(){
    $("#45").click(function(){
    $("tr #k" + this.id).remove();   
    })
    })
    </script>
    <table>
    <tr>
    <td><span id="k45">xxxxx</span></td>
    <td><input type="button" id="45" value="click to remove"></td>
    </tr>
    </table>
      

  4.   

    这样可否行得通??
    hid ="Cut1|580021-00|42|Cutorder|CutID"
    var hidarr = hid.split("|")
    $("tr #k" + hidarr[2]).remove();
      

  5.   

    hid  值是  this.id 过来的。
      

  6.   

    alert("tr #k" + hidarr[2]) 正确就可以
      

  7.   

    $("tr").each(
        function(){
         var id = $(this).attr("id");
         $("#k"+id).remove();
      }
       );