,在我的剧本,我想选择由他的动作和控制器的名称li元素,我可以检索数据一样宽度和位置从具体的li元素。
我的功能看起来像这样,但我不知道如何选择器看起来像。
function currentItem() {
//Here i get the current view and controller name
var actionName = '@ViewContext.RouteData.Values["Action"].ToString()';
var controllerName = '@ViewContext.RouteData.Values["Controller"].ToString()';
// something like that, putting the link together?
var $currentItem = $('a[href="' + viewController + controllerName + '"]');
// or find all elements by class name an than do something like
var myArray = $('.navItem');
if (myArray[0].Controller == controllerName ||myArray[0].Action == actionName) {
$currentItem = myArray[0];
}
return $currentItem;
}
感谢您的帮助。
弗朗胡
2014-02-19
Franhu