编辑:我尝试了下面给出的所有解决方案..还有 3 个外部文件..我认为它们覆盖了设置..我也在下面粘贴它们
我在 Jquery 中有一个动态表。我想使其第 3 列记录 MZillaID 超链接
这是我的代码:
function getErrorStatusList() {
$.ajax({
//data comes in response
success: function (response) {
obj = response.d;
var output = "<table class='table'><tr><th>Serial No.</th><th>UFZillaID</th><th>MZillaID</th><th>Status</th></tr>";
for (var x = 0; x < obj.length; x++) {
output += "<tr><td>" + (x + 1) + "</td><td>" + obj[x].IssueID + "</td><td class='myclass'>" + obj[x].EMID + "</td><td>" + obj[x].EMStatus + "</td></tr>";
}
output += "</table>";
$("#result").append(output);
},
});
我想做 记录超链接...我们可以在 CSS/Jquery 中做到吗??我在特定列上创建了一个类(myclass)。但我不知道如何进行。此列的记录已经是超链接,但已被其他 css 覆盖。
请提出建议。任何帮助都会有帮助
最佳答案
附加 anchor <a>
第三列内的标签- <td>
output += "<tr><td>" + (x + 1) + "</td><td>"
+ obj[x].IssueID + "</td><td class='myclass'><a href='"+obj[x].EMID +"' style='text-decoration:underline;'>"
here^
+ obj[x].EMID + "</a></td><td>" + obj[x].EMStatus + "</td></tr>";
here^
或者在你追加之后使用 .wrap()
,
$("#result").append(output);
$("#result table td:eq(2)").wrap('<a href="'+url+'" style="text-decoration:underline;"></a>');
CSS:
a{
cursor:pointer;
text-decoration:underline;
}
Demo
关于jquery - 如何将动态表的1列记录转换为超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24278157/