我有两个社交媒体链接fb和insta..如何提供单独的哈希链接以及如何更改文本颜色示例FB蓝色,insta颜色黄色 - JavaScript
let t_p_data = [{ s_media: 'Facebook',},
{s_media: 'Instagram',},];
let paymentsData = $('.payments-data');
paymentsList = paymentsData.innerHTML;
for (let p_data of t_p_data) {
paymentsList += `<tr><td><a href="">${p_data.s_media}</a></td></tr>`
} paymentsData.append(paymentsList);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table><tbody class="payments-data"></tbody></table>
如果你想在循环中设置哈希链接和文本颜色,那么你必须在t_p_data中给出它们:
let t_p_data = [{ s_media: 'Facebook', link: 'fb.com', style: {color: '#00f'}},
{s_media: 'Instagram', link: 'insta.com', style: {color: '#ff0'}}];
,然后在循环中添加信息:
for (let p_data of t_p_data) {
paymentsList += `<tr><td><a href=${p_data.link} style=${p_data.style}>${p_data.s_media}</a></td></tr>`
} paymentsData.append(paymentsList);