Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将标签更改为jquery库中的链接_C#_Javascript_Jquery_Asp.net_.net - Fatal编程技术网

C# 将标签更改为jquery库中的链接

C# 将标签更改为jquery库中的链接,c#,javascript,jquery,asp.net,.net,C#,Javascript,Jquery,Asp.net,.net,我有一个asp.net mvc4应用程序,我想在其中添加一个treeview。所以我使用了这个Jquery库: //显示UCLA CS类依赖项(不完整) $(文档).ready(函数(){ var width=$(文档).width()-500; var height=$(document.height(); var g=新图形(); g、 edgeFactory.template.style.directed=true; g、 附录(“项目”、“基金1”); g、 附录(“附录1”、“附录1

我有一个asp.net mvc4应用程序,我想在其中添加一个treeview。所以我使用了这个Jquery库:


//显示UCLA CS类依赖项(不完整)
$(文档).ready(函数(){
var width=$(文档).width()-500;
var height=$(document.height();
var g=新图形();
g、 edgeFactory.template.style.directed=true;
g、 附录(“项目”、“基金1”);
g、 附录(“附录1”、“附录1.1”);
g、 附录(“附录1”、“附录1.2”);
g、 附录(“项目”、“基金2”);
g、 附录(“第2款”、“第2.1款”);
g、 附录(“第2款”、“第2.2款”);
g、 附录(“附录2”、“附录2.3”);
g、 附录(“第2款”、“第2.4款”);
var layouter=new Graph.Layout.Ordered(g,拓扑_排序(g));
var renderer=new Graph.renderer.Raphael('canvas',g,width,height);
});
结果是这样的视图:

这很好,但我需要将每个标题更改为如下链接:
@Html.ActionLink(“Projet”,“Modify_Project”)


如何修改代码段以执行此任务?

如果您使用的是jQuery

// on page load
$(function(){

// You need to identify a selector that selects all the titles you want to change..
// Likely they all have a certain class 
$('.titleSelector').changeElementType("a");

// Now you probably want to add an href
$('a.titleSelector').attr('href','http://youlinkhere');

});
这是插件。。在jquery加载之后和脚本运行之前包含它

(函数($){
$.fn.changeElementType=函数(新类型){
var attrs={};
$.each(此[0]。属性,函数(idx,attr){
attrs[attr.nodeName]=attr.nodeValue;
});
this.replaceWith(函数(){
返回$(“”,attrs.append($(this.contents());
});
};
})(jQuery);
// on page load
$(function(){

// You need to identify a selector that selects all the titles you want to change..
// Likely they all have a certain class 
$('.titleSelector').changeElementType("a");

// Now you probably want to add an href
$('a.titleSelector').attr('href','http://youlinkhere');

});
(function($) {
    $.fn.changeElementType = function(newType) {
        var attrs = {};

        $.each(this[0].attributes, function(idx, attr) {
            attrs[attr.nodeName] = attr.nodeValue;
        });

        this.replaceWith(function() {
            return $("<" + newType + "/>", attrs).append($(this).contents());
        });
    };
})(jQuery);