遇到一个小项目的问题,我在过去的3天里一直被困。。。我必须使用javascript&jquery在一个单独的js文件中由于问题的限制,我无法编辑html文件。
我希望我能正确理解你的问题。您可以使用选择器.code
访问单元格,然后使用append()
在其中放置链接,如下所示:
$(".code").each(function(i){ //find the right cells and for each one...
var text = $(this).text(); //...read the contents...
text = text.substring(3); //...remove the first 3 letters...
$(this).text(""); //...remove the text...
$(this).append("<a href='"+text+".html'>"+text+"</a>"); //...and replace with a link
});
示例:http://jsfiddle.net/7fawbkck/2/