简体   繁体   中英

onclick / anchor tag- javascript in HTML

Can someone help me on how to add anchor link/ onclick to a datarow

  for(i=0;i<10;i++){
          dataRow1 = dataRow.insertCell(0);
          record =  document.createTextNode(returnedValues[i].Name);   
          dataRow1.appendChild(record);
        }

Your question is not clear, I assume this might be helpful:

// Create anchor tag
const a = document.createElement('a');

// Add link
a.href = 'http://yourlink.com';

// Add Text
a.innerText = 'Custom Link';

// `dataRow` should be a HTML Element
dataRow.appendChild(a);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM