Rita
Rita

Reputation: 921

JQuery Treeview Highlight the Background color for the Child Node that is clicked on ASP.NET MVC Page

I have an ASP.NET MVC Page that has Left Menu navigation that is built using JQuery Treeview as in Demo #3 in http://www.dynamicdrive.com/dynamicindex1/treeview/index.htm

Here I made Childnode as href link so that rightside main partial view is loaded.

Now for the chicldnode that is clicked, I want to highlight the background-color.

Wondering how to do this?

Appreciate your time.

Thanks

Upvotes: 0

Views: 3651

Answers (2)

hunter
hunter

Reputation: 63522

jQuery

$(".treeview a").click(function(){ 
    $(this).css("backgroundColor", "blue");
});

CSS

What would be better so that you don't have multiple 'blue' background'ed anchor tags is just extend their 'selected' class:

.treeview a.selected { background: blue; }

Upvotes: 1

Ravinder Singh Bhanwar
Ravinder Singh Bhanwar

Reputation: 824

Try this trick also :-

$(".treeview a").click(function ()
 {

      $("a").css("backgroundColor", "");

      $(this).css("backgroundColor", "blue");

 });

Its works for me tested ... May b help full for you :::

Upvotes: 0

Related Questions