I would like to have same kind of effect for the submenu items ie When a menu item is selected(clicked) it should be highlighted.
Now the catch is, for my website when a item of submenu is clicked the main url at address bar will not change. anchor links will be placed within the content of the same page. As a click on item should bring up the content as well as highlight the item.
I have attached a basic framework of HTML and CSS (test.zip)to demonastrate how my webpage will be.
If it can be done in HTML/CSS will be great. Not much aware of PHP or ASPX.
However if it cannot be done trough purely HTML & CSS, I will really appreciate if some one can provide the other solution.
I understand your logic, however I’m not much familiar with JavaScript/jquery. Tried to implement the idea however not been able to get the result. It would be very kind to have a look at the files again i have attached. i must be be doing some silly mistake which I’m unable to determine. Thanks for your help.
Please have a look at the attached files. done as per the reply i received. But still can’t see the item is highlighted when it is clicked. Must be some silly mistake at my side. However I’m not able to figure out. Thank you for your help.
Regards
PS: i figured that last zip attached is wrong(dont know if i can delete that)
Nothing wrong with it, it’s just that the jQuery library is 24KB, which is kind of overkill if you’re only going to use it for menu highlighting.
Using plain ol’ javascript is better for that.
So, purely for the sake of bandwith usage I’d say.
Oh no the code will execute alright.
All I’m saying is that using jQuery to highlight the menu is like using a tank to shoot a bug. You could do it, but it’s really overkill.
Anchors aren’t self closing and you need to to do it like so:
<a name="tier1"></a>
However you would be better of removing the named anchors and using an id on the headings instead for the same effect.
e.g.
<h4 [B]id="tier2"[/B]>Tier 2</h4>
The jquery method avoids having onclick attributes in your html as it handles this unobtrusively and keeps the html clean although as mentioned it is rather overkill for that one small job.
Glad that you have something working now but I have to ask if you are going about this the best way.
It’s not generally a good idea to have your whole site as one page for many reasons. If you are just flipping through a few short sentences then a hide and show effect is ok but if you are displaying a page of content each time then you would be better off with a proper site and call up a different page each time and avoid the need for any JS at all.
This would improve accessibility and also aid seo at the same time. Having a one page site is akin to using “Frames” and we all know what happened to them
I may have got the wrong impression from the short amount of code you posted but I thought (was prompted) that I should say something.
Also in the code you posted there was not a correct page structure and no doctype etc but I guess that wasn’t the full code - just a snippet. Make sure you use all the html elements that you are supposed to including the doctype or you will run into problems with IE.
Thank you Paul O’B;4582004 for pointing this out. I shouldn’t have said “Website” rather appropriate might be a html 'Page". Yes you are right, this will be for a page for the website, there will be few paragraph of content. A click on left side will get the right paragraph up for the user.
Yes, I do have doctype in the actual page. I thought just to create prototype snippet rather that pasting the entire actual code.