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

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

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

javascript - Restarting Supervisor and effect on FlaskSocketIO -