insert href into table cell using javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • visweswaran2830
    New Member
    • Nov 2009
    • 92

    insert href into table cell using javascript

    Hi,

    I want to insert href into tabel cell using javascript. Note should support all browser.

    I know to insert, but it support only in IE, I checked in firefox, it does not support so please help me.

    This is code to insert(works in IE)

    Code:
    var myLink = document.createElement('a'); 
    var href = document.createAttribute('href'); 
    myLink.setAttribute('href','javascript:removeRow('+pos+')'); 
    myLink.innerText ="Delete"; 
    newCell.appendChild(myLink);
    Last edited by Dormilich; May 12 '10, 12:21 PM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    .innerText is only supported by IE. either explicitly create a Text node or use .innerHTML or .textContent.

    PS. you don’t use line #2 at all …

    Comment

    Working...