That way the links still get you down to the appropriate content when scripting isn’t there.
Then, assign an onclick event to the menu which triggers a function which hides each of the content sections, and then shows the one that the link links to.
You can also then run that function when the page starts to hide all of the content.
Hi,Thank you for the reply,ahm I mean to do this in jquery?I do apologize i am not good in this language i am still learning.I hope you can help me.
I want that when i clicked the Link1 which is Link1.php this will load to my Div Content which is on the right side.Thank you in advance
Yes i will not let you do that of course you must give me a chance to do this in my own,what i want is to ask some idea on how can i achieve this and please guide me so that i will not be lost.Thank you so much in advance.
Hi, i am trying to put some alert so that i can test when i am going to click the link if my code is working,but it failed to alert what is wrong with this?
Sure thing. The each method takes a function, and in that function the this keyword refers to each different element, in this case it’s each anchor link in the menu.
Your HTML needs to be changed so that each link points to a different div. That way your function can get the href attribute from each link with $(this).attr(‘href’) so that you can then use that reference to the div to hide it.
so that you can then use that reference to the div to hide it.
Why do i hide the div?i want to load the page in the Div with an id of content…example when i click the link “search name” in the menu list.the page1.php will load to the Div id=“content”.because the page1.php have textboxes and table,and this is something like displaying user profile…just like other links when i click the link fname the page2.php will load to the <div id=“content”> and this will display also table and displaying the user fname,age.etc…
The main reason is for when you click on another link. You If link 2 is showing and you click on link 3, you don’t want link 2 to still be showing. But when you click link 3 the code doesn’t have an easy way to tell which one was already open. So the most effective standard procedure to deal with that is to hide all of the ones that the links point to, and to then show the one that was clicked.
The different parts of your content need to be in separate identified divs.
Your links need to link to those identified divs.
Your script needs to go through each of the menu links (not the content ones) and use the link as a selector so that you can hide the target.
Your script also needs to use the link of the one that was clicked, to show the target of that link.
and use the link as a selector so that you can hide the target.
Your script also needs to use the link of the one that was clicked, to show the target of that link
I have no idea on this,can you please show me what you mean?
After you’ve done that, it’s not $(this) that you need to hide (because $(this) is the link that was clicked on), but instead it is what the link is linking to instead that you need to hide. That’s most easily achieved by using this.hash for the selector, which retrieves the fragment identifier from the link. An example of a fragment identifier is “#content2”
With showing the target of the link, after you’ve hidden the other ones you need to show the one that the clicked link refers to. So at the end of the function for the click event you will want to use the fragment identifier of the clicked link to show what the link is linking to.