jquery - Javascript menu bold selected, un-bold the rest -


i have asp mvc app has menu javascript behind move page page. now, when select menu item, becomes bold. stays bold when select different menu item. if click menu items, become bold , stay way.

here code 1 menu item:

<script>     $('#firstmenuitem').click(function () {         $('#div').load(             "@url.action("firstmenu","someitem")",             { 'id':'123'},              function (response, status, xhr) {                 if (status == "error") {                     alert("an error occurred while loading data.");                 }             });         this.style.fontweight = 'bold';     }); </script> 

i want change code when select menu item, 1 become bold, , rest normal font.
how this?

jquery provides siblings function can use, assuming menu items live in same parent element.

$(this).siblings().css('font-weight', 'normal') 

here's quick demo: https://jsfiddle.net/terbt1lt/


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -