Search code examples
javascriptjqueryhtmlapex-code

Removing some text data in HTML file


I am working on visualforce pages. below is given the part of HTML file code that has been generated after executing the apex code.

<table class="detailList" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr></tr>
<tr>
    <td class="labelCol"></td>
    <td class="dataCol col02">  userName <a href="www.example.com"></a></td>
    <td class="labelCol"></td> <td class="dataCol"></td>
  </tr>
  <tr>
    <td class="labelCol"></td>
    <td class="dataCol col02"><a href="mailto:[email protected]"></a></td>
    <td class="labelCol"></td>
    <td class="dataCol"></td>
 </tr>  
</table>

I want to remove the userName anchor tag from this page which is coded in line# 6 whose class Name is "dataCol col02", and there is another anchor tag with the same class name "dataCol col02" at line# 11. keep it in mind that this html is generated by executing an APEX code. Kindly guide me how could i remove the anchor tag at line#6 only..


Solution

  • Use this

    $(function(){
      $(".dataCol.col02:first a").remove(); 
    });
    

    Demo