33436

How to make menu by using Master Page with jquery?

Question:

nowadays i m making one mvc project and i use master page i wanna make menu with items have active preferences i used $(document).ready(function() { //document

$('#tabMenu > li').click(function() { //clik if (!$(this).hasClass('active')) { //if $('#tabMenu > li').removeClass('active'); / $(this).addClass('active'); } //endif } //click

); } //document ); and html menus/* /*ul id="tabMenu"> <%= Html.ActionLink("Home", "Index", "Home")%> <%= Html.ActionLink("About", "About", "Home")%>

</ul>*/

it is working but just 1 second becoz master page load its menu and so how can i solve this problem?

Answer1:

Your question is not very clear...

The following code works... Maybe this helps?

<html> <head> <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script> <style type="text/css"> #tabMenu li {display:block;float:left;background-color:green;} #tabMenu li a {color:white;} #tabMenu li.active {background-color:blue;} </style> <script type="text/javascript"> $(document).ready(function() { $('#tabMenu > li').click(function() { if (!$(this).hasClass('active')) { $('#tabMenu > li').removeClass('active'); $(this).addClass('active'); } }); }); </script> </head> <body> <div id="menu"> <ul id="tabMenu"> <li><a href="#">MenuItem</a></li> <li><a href="#">MenuItem</a></li> <li><a href="#">MenuItem</a></li> </ul> </div> </body> </html>

Recommend

  • Heap sort implementation with linked list and arrays
  • IE everlasting problem with selectors
  • Why intent is not passed from adapter class?
  • How to mock a react component's event when fat arrow function is used as event handler?
  • map map return flat array in jQuery
  • setTimeout not delaying function call in $.each
  • Getting undefined response from jQuery AJAX form post
  • Anchor from another page not working in Firefox and IE (works in Chrome)
  • Loading dynamic div content with jQuery from a URL
  • z-index issues with jQuery Tabs, Superfish Menu
  • Safari blurs strange bugs
  • How do I remove an element class after success?
  • jquery bind submit event - find caller
  • html table selection with colspan or rowspan
  • clear interval doesn't work
  • When activating OLEControl in my PowerBuilder application, toolbar items disappear
  • Limit the number of visible pages in pagination
  • Fading between images
  • Laravel : having the same element on each of my pages
  • jQuery panel slider opens with button click but won't close
  • jquery if else condition for css api
  • Flot returns incorrect x value (mm/dd/yy - date) after zoom for stack bar chart
  • Get css animation property with jQuery
  • 'Enemy' was not declared in this scope?
  • PayPal API Listener Website Payments Standard URI
  • redirect_to root_url and return unless @user.activated
  • Ajax Upload File: $_FILES is empty but files exists in request header
  • Using jQuery closest() method with class selector
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Menu Color Fade on Hover with Jquery
  • Jquery - Jquery Wysiwyg return html as a string
  • How to get icons for entities from eclipse?
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • How to stop GridView from loading again when I press back button?
  • JaxB to read class hierarchy
  • Observable and ngFor in Angular 2