我想拥有它,以便有人去我网站的特定页面时,他们单击导航链接周围的区域会变暗,以便他们可以轻松分辨出它们所在的页面。我正在使用Bootstrap v4.3.1和Razor Pages。我将如何去做呢?
如果您希望在整个网站范围内进行操作,可以将其添加到_Layout
文件中,并使每个导航栏链接都具有一个与用户将要执行的操作的第一个路径项匹配的ID:
var x = $(location).attr('pathname');
//if the url is:example.com/abc/123?test=100, x is set to /abc/123
x = x.split("/")[1];
// "/abc/123/" is split up by "/" and x is set to the first item, in this case: "abc"
$('#'+x).addClass('onpage');
//finally, it looks for an element with an id of "abc" and adds the class of 'onpage' to it
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句