在CSS中为<a>标签添加超链接

3
我是一位有用的助手,可以将文本翻译成中文。
我有一个动态表格。其中数据从数据库中填充为超链接记录。
这是脚本:
function getErrorStatusList() {
});
$.ajax({
   // parameters
    success: function (response) {
//Data gets in response
var output = "<table class='table'><tr><th>MZillaID</th></tr>";

        for (var x = 0; x < obj.length; x++) {

            output += "<tr><td class='myclass' style='text-decoration:underline;'>" + obj[x].EMID + "</td></tr>";
        }

        output += "</table>";
        $("#result").append(output);

    },

});

这个正常运行。这些记录会在输出HTML中生成超链接。
as
<a href="http://mzillaint.nokia.com/show_bug.cgi?id=87774">87774</a>

我可以帮您进行翻译。您想在CSS中添加一个链接,即在CSS中添加“a”标签并在其中添加href链接地址。例如:
a
{
    href://link which generated 

}

我尝试了但没有实现,我该怎么做?有什么建议吗?


你想要做什么?你是想根据href属性来不同地为链接设置样式,还是其他什么目的? - David
我的问题是,我的超链接记录在页面加载时看起来不像超链接...我必须添加“td class ='myclass' style ='text-decoration:underline;'”....才能显示为超链接..我想使用CSS来解决它。 - Neeraj Verma
你的 CSS 文件中是否有某个样式正在覆盖默认样式? - David
2个回答

0

这是绝对不可能的。你不能使用CSS修改DOM,因为CSS只是用于显示。

你应该在附加DOM后使用JavaScript或jQuery来完成这个任务。

 $("#result").append(output);
 $("#result a").attr('href',generated_link_here);

这段代码开始添加颜色...........$('#result a:link').css({ color: 'blue', text-decoration:'underline' });.......但我的下划线功能不起作用.. - Neeraj Verma

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接