JQuery :: Add And Remove Classes When Clicking On The Main Menu Links?
Sep 9, 2009
I have a problem with my menu. I am trying to add and remove classes when clicking on the main menu links. For instance when on load, the 'Home' is the current tab clicked, but when I click on 'Contact Me' I would like the class current to be removed from 'Home' and added to
'Contact Me' instead.</div>
<div> </div>
<div>The code im using is the one below.</div>[code]....
View 1 Replies
ADVERTISEMENT
May 29, 2009
I'm having trouble making a main vertical navigation with two drop down menus and wondering if anyone can please help as I'm not great with javascript! I have a main menu and two drop down menus. At the moment I get them to open fine when the main link is clicked and close when it is clicked again. But I want dropdownmenu1 to close when opening dropdownmenu2 so that they are not open at the same time!
This is my javascript:
<script type="text/javascript">
function showElement(layer){
var planLayer = document.getElementById(layer);
if(planLayer.style.display=="none"){
[Code].....
View 4 Replies
View Related
Dec 20, 2011
Lets say I have something like code...
View 1 Replies
View Related
Feb 7, 2010
I've hit a little bit of a road block developing this site: [URL]. I'm attempting to use the thumbnails to load a new video in the main object. I've used this:
$(document).ready(function(){
$('.thumbnail').bind('click', function() {
new_video = $(this).attr('href');
$('.main_video').attr('src', new_video);
$('.main_video').siblings('param').attr('value', new_video);
return false;
});
});
To replace the attributes in the object, but at this point, the source has the new arguments, but it needs to reload as the actual element still contains the old video. Should I somehow use AJAX to refresh this div? Should I reconstruct my jQuery somehow?
View 5 Replies
View Related
Oct 27, 2011
How do I get href links from classes & append/prepend them to some element. My attempts...& many other I can't mention
[URL]
View 12 Replies
View Related
Aug 12, 2010
For the HTML I have
<span id="one">Vestibulum </span> <span id="two">tortor</span> <span id="three">quam,</span>
for the JS I have
$("button").toggle(
function () {
$("span").removeClass("big");
[Code].....
this cycles through and does what i need, however i have like 100 span tags ... is there a way to do this without having to identify every span ID ?
View 4 Replies
View Related
Aug 26, 2009
My menu navigation(Home, Hosting Solution, etc..)
1. The submenu links need to be centered in the middle of the div instead of aligned to the left.
2. Can the submenu links have a rounded box appear under them, instead of being underlined links. Like these at the top: [url]
3: The top tab needs to stay gray/active/on when the mouse is moved down to the submenu or when it is the active button.
Here is the link of the site [url]
View 2 Replies
View Related
Sep 21, 2011
I have an ajax script which loads new content onto the page when the main navigation links is clicked. I also have a jquery script which fades divs in and out when another subset of links are clicked.
I guess these scripts essentially do the same thing but the first basically is loading in 'pages' without the page having to refresh. The second is just fading in and out divs that are on a page.
The problem is is that the second script only seems to work once, when the page is loaded.
Here they are:
View 2 Replies
View Related
Dec 19, 2010
I'm relatively new to jQuery, and I'm trying to figure out how to create a restaurant menu, that when you click on an item on this menu, an image and description will show on the page. [URL]I've looked through several plugins but cannot find this exact solution. Can anyone please point me in the right direction?
View 2 Replies
View Related
Nov 7, 2011
I use malsups Cycle plugin a lot as it is very versatile, however when I have a pager with a slider and click through to the next slide (whilst current slide is animating) it jolts to the end of the current slide transition before continuing with the next slide transition. Example: [URL]. Ideally, when you click on the next pager link, (before it has finished sliding), it finishes it's animation and scrolls to the next OR slides from it's current point on the current transition to the end of the next slide.
View 3 Replies
View Related
Jan 13, 2011
I'm trying to add a very simple gallery where the photo is at the top and thumbnails are underneath. All I want to happen is that the photo changes when you click on one of the thumbnails. I've been trying to search for this but the galleries all seem to have stuff I don't want.I tried the following and it does change the image but it also opens up the thumbnail.
Code:
<img id="im" src="photos/039.jpg">
<a href="photos/t001.jpg" onclick="document.getElementById('im').src='photos/001.jpg'"><img src="photos/t001.jpg"></a>
View 7 Replies
View Related
Oct 24, 2010
Using 1.4.1. A comments app. Clicking certain links fetches a comment form which displays below. The button then becomes a "cancel" link. Clicking that removes the form and sets the button back to its original state. Or so it should. I'm seeing some strange behavior. Some strange, but understandable, some not so much.
Basic code:
After removing the form, my code fetches it again and re-displays it. The problem appears to be that click event isstill "happening" and so live() fires immediately. I tried using stopPropagation(), which keeps the form from re-loading but for some reason also keeps displayFormHandler from being run on subsequent clicks.
I saw a hint in the comments for stopPropagation() and added, in cancelFormHandler:
And:
Again, this keeps the form from re-displaying but, bizarrely, causes displayFormHandler to always return false (the console.log() line runs every time). I can understand why the original problem happens but this doesn't make any sense at all. If the class has been removed, subsequent clicks should proceed normally because hasClass() is being evaluated at the time of the click, not when live() is called.
View 3 Replies
View Related
Nov 5, 2010
I have a mega menu that when the main menu items is hovered over the mega menu the div is displayed. I want to keep the div from being shown off the right of the browser screen. I have the following that determines the amount a div is off the right of the browser:
Code:
function keepMenuLeft(){
var div_width = $("li.hovering div").width();
[code]....
View 1 Replies
View Related
Nov 26, 2004
I am in a bit of a rut in the self-teaching with JS. I am trying to get links to change the external js file currently on the main page without reloading, the external files are basically long document.write sections with a few interactive functions.
The closest I have found for help with this so far is a rotating script, but I want a manual change from a link (button, image, etc) instead of timeOut rotation. I am not sure what I need to do for the links to replace the timeout function to change the dynamic section.
View 4 Replies
View Related
Mar 8, 2010
provide me with code to make a collapsible menu? What I'm looking for is a vertical menu, that will open up the sub-categories upon a mouseover. Clicking on the menu item will bring them to the specific page. Oh, and this might not matter, but I'd prefer if I was able to style the menu to fit with my site theme.
View 2 Replies
View Related
Jun 4, 2011
My goal right now is to make a two-part navigation bar where you don't have to reload the whole site, when you click on a link. The navigation bar consists of two <ul> lists with <li> float:left and <a> display:block, so I basically have two lines. It's probably easier to understand if you see it for yourself: jsfiddle (had to change the css style, because I use .less but it works)
When you load the page it's just like that, you have your main category (A,B,C,D,...) and the sub-category (A1,A2,A3,...). What I want: If you click on B, the sub category changes to B1,B2,.... If you click on a sub category the site loads the requested page (with ajax = best solution?!)
My thoughts
At first I thought about just changing the name and href attribute of the second list, but the main categories have different amounts of sub categories, so I would need to add or remove <li>'s. Then I thought about using .load() but I somehow screwed up (of course) and the loaded <ul> doesn't have any css style (wrong order?) and I can't see anything. (with a loaded test.html site containing only the word "test" it worked) Is ajax "overkill" as a solution?
CodeIgniter and the URL
I use CodeIgniter (a PHP framework) for the website and URLs like this: www.example.com/maincategory/subcategory (e.g. example.com/A/A3) That's no problem at all, if I don't use any javascript and reload the whole site every time. But is it possible to change the URL with jQuery when the user clicks through the navigation bar? You click on B, the URL changes to example.com/B all the subcategories change to B1,B2,...When you click on B2 the URL changes to example.com/B/B2 and the site loads the requested page (I guess with ajax, so the navigation stays the same?!)
Minor problem: when you load the site, click on B, then B3 for example, you would get the url example.com/B/B3. If you now save this link, close the site and reopen it with the link, CodeIgniter would load the right site and everything, but the navigation would show A1,A2,.. in the sub category.
Hover vs click
Almost every page where I saw this kind of menu they used hover to change the sub category. But I thought click would be better, so you don't have to avoid touching B,C,D,.. if you want to go from A to A9 for example. Only downside is that you have to click before you see the sub categories.
Summary
A two part navigation menu you can use without reloading, changing URLs (when possible) and probably ajax to load the actual content.
View 2 Replies
View Related
Apr 6, 2011
But I am doing both front and backend for a project and having an issue with a jquery slider which, when inserted, is breaking 2 other js scripts in the page, including my main menu.Can anyone point me to a resource that outlines best practices for working with more than one js library and/or raw js .I'm doing some tests on the order of the scripts right now, but wanted to put a feeler out there to see if someone has dealt with this before.
View 1 Replies
View Related
Jan 14, 2010
I have all links that is needed to be click on so what I want to do is, after they click all 4 links, it will enable the button. I know that we have to do this in Javascript but I'm stuck.
Example, there 4 links, after they click all links, it will enable the button.
View 3 Replies
View Related
Mar 18, 2005
I have a pages with list of sites and when I click on links to other domains, the other domains will see the referer where I clicked from. How can I avoid the referer when clickin on links on my page? (I don't want to click new IE browser and paste the url).
View 3 Replies
View Related
Feb 18, 2010
How can add and remove input field by clicking on a button. EX:
<input type="text" id="name">
<input type="text" id="email">
<input type="button" value="Add More fields">
When you click on Add more fields, input fields name and email needs to be duplicated and REMOVE button must appear to be able to remove them if neccessary.
View 1 Replies
View Related
Dec 7, 2010
I'm looking for a Javascript workaround that'll allow me to indicate the current page on the main menu(basically, the menu button for that page will be a different colour to the rest of the menu buttons). The main menu is in CSS but isn't bringing up the required image for the "current menu item" indicator automatically and no one knows why.
View 1 Replies
View Related
May 21, 2009
. I have a problem where I designed my web page project and eventually it must contain a background song that will continuously play even clicking the links/pages.
View 5 Replies
View Related
Mar 20, 2011
I'm trying to build a web portfolio and I want to be able to load content into a div by clicking on menu items. It seems easy but none of the tutorials or videos work for me. It really hard because all the links on my google search have been visited and still nothing works.
View 3 Replies
View Related
Sep 20, 2010
when a user clicks on a link, a new window opens. what I want to do is that if the user closes that popup but click on that same link again, the window should open..
Code:
<script language="javascript">
var winOpen = "";
[code]....
View 1 Replies
View Related
Mar 23, 2009
I'm designing a web page, Having a banner on top, then a search option following it.
There is a menu item list below it on to the left.And the content of the links of those menu item should get loaded in the center of the page.And a footer having some copyright info.All these are in div tags.
The problem is when i click on any menu item it should be loaded in the center div tag.Ive tried using Iframes but there is a scrollbar coming only in that area of center div tag.I don't wan't this to happen.Based on the size of the html page to be loaded the div tag size should increase, and so the whole page.Have tried using Ajax but not working.
View 1 Replies
View Related
Jul 27, 2010
I have an animated main menu that uses slideDown() to show the sub-menus, triggered by the .hover() event on the parent. There's another animation on the home page that uses jCarousel to rotate the items in a <ul> every three seconds. Whenever a hover event on a parent menu item coincides with the animation trying to load a new frame, the menu freezes until the other animation is loaded. As common as animated menus are these days, I can't believe I'm the only one who has ever come up against this problem.What I want is for the menu animation to take precedence no matter what, but I understand that JS has no "priority" feature (not being multi-threaded)
View 3 Replies
View Related