Question

im beginner in jquery, i need to horizontal accordion menu by using jquery, i found couple of code but i cant use them within master page and content page in asp.net 4.0. how can i define jquery method in asp.net masterpage and content page....here is the jquery sample i wanna use in my page...

contentpage header

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link href="slidemenu.css" rel="stylesheet" type="text/css" />
<script src="slidemenu.js" type="text/javascript"></script>

endcontent header

maincontent

<script type="text/javascript">
    $('#MainContent').load(Function(){
    slideMenu.build('sm',200,10,10,1);
    });
</script>

here is ul and li tags withi

endmaincontent

Was it helpful?

Solution

To ensure that the DOM hierarchy is fully constructed and the #MainContent element exists, call the required jQuery script within the $(document).ready function:

<script type="text/javascript">
$(document).ready(function() {
    $('#MainContent').load(Function(){
        slideMenu.build('sm',200,10,10,1);
    });
});
</script>

.ready() - jQuery API

OTHER TIPS

try moving the script tag into your content page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top