Script Which Adds A Class To The Current Menu Item Selected

Aug 6, 2011

I have a small script which adds a class to the current menu item selected.

Currently on the page load (this menu is within one page) the first menu item which is loaded does not have this .mywork_active class. Its not until you click it or another item that the class is added.

What would I need to do make the script add this class to the first item on load.

The menu looks like so:

View 1 Replies


ADVERTISEMENT

Apply Selected Attribute To Current Select Box Item

Feb 9, 2010

I've created the simple select box below that will "onchange" when an item is selected. I'm trying to apply the "selected" or "selected="selected" attribute to items that are chosen from the menu. Example: The goal is to show " <option value="/1" selected="selected"> " when page "/1" is chosen and to show <option value="/1"> when /1 is not the current page. I've follow a few simple tutorials with no luck and even tried php conditionals to trigger the "selected" attribute with no luck.

<form name="guideform" method="get">
<select class="wptdb_jumpbar_select" name="mymenu" onChange="window.location=document.guideform.mymenu.options[document.guideform.mymenu.selectedIndex].value">
<option value="/1">Home Page #1</option>
<option value="/2">Home Page #2</option>
<option value="/3">Home Page #3</option>
<option value="/4">Home Page #4</option>
</select>
</form>

View 4 Replies View Related

JQuery :: Change Opacity Of Item With Class Of Selected

Jan 5, 2010

I am trying to check if a list item has a class of selected, then is so change the opacity to 0.5. Here is my code:

[Code]....

View 6 Replies View Related

Apply CSS Class - Selected Item As The Background Color Won't Change?

Apr 28, 2009

This is for an online quiz that collects selected answers through hidden checkboxes, and when a checkbox is selected the javascript changes the background of that selected item. However the problem is when javascript is disabled the whole thing won't work because the checkboxes have a class of .hide which, obviously, hides them and the user can't see that they've actually selected an item as the background color won't change. So I was thinking that instead the javascript could apply the class of hide to the input. That way if it's disabled the checkboxes will show.

<style type="text/css">
.hide { display:none;
*display:block;
*margin:0;
*padding:0;
*width:0px;
}
</style>
[Code]...

View 1 Replies View Related

JQuery :: Superfish Submenus Open Under Current Menu Item

Aug 16, 2011

I'm trying to get Superfish menus working on a new site I'm building, but have run into a problem. I have used the feature of setting a class on the current menu item so that it will be highlighted (highlit?). The trouble is that if the menu item has a submenu this submenu is displaying already opened when you hit the page.

I've set the menus up with the following options:
$('ul#nav').superfish({ hoverClass: 'sfHover',
pathClass: 'current',
pathLevels: 1,
delay: 800,
animation: {opacity:'show'},
speed: 'normal',
autoArrows: true,
dropShadows: true,
disableHI: false
});

This is a snippet of the menu code just for completeness, although it's pretty generic:
<ul id="nav">
<li><a href="index.html">Home</a></li>
<li class="current"><a href="agenda.html">Agenda</a>
<ul>
<li><a href="stream_busdev.html">Business Development Stream</a></li>
<li><a href="stream_techsupp.html">Technical and Support Stream</a></li>
<li><a href="stream_partners.html">Partners Stream</a></li>
<li><a href="stream_paytrain.html">Payroll and Training Stream</a></li>
</ul></li>
... more menu items in here ...
</ul>

I've also attached a screengrab, in case it helps, since the site isn't live yet. So I guess what I'm asking is: is there a way to have the current parent menu item marked as current without it automatically opening the submenu?

View 5 Replies View Related

Highlight The Selected Menu Item?

Jul 9, 2010

I have a javascript list menu, I want the menu item stay in given background color when we are at that page. How do we achieve that with javascript?

View 9 Replies View Related

Detecting Which Context Menu Item Was Selected

Jun 29, 2006

I have a TEXTAREA element. A user right clicks within in to get the context menu and they select "paste". I want my javascript code to know that they selected "paste". I know you can capture the mouse click, but can we capture exactly what event that attempted?

View 3 Replies View Related

JQuery :: Alter Selected Menu Item?

Jun 5, 2009

I can access the drop-down value(s) the visitor has chosen by $("#ak option:selected").each(function () {... but now I want to force the drop-down list to be selected to a particular default value of my choosing ... how would I do this?I did try:

$("#ak option:selected").each(
function () {
$(this).text('-> Choose Accessory kind');

[code].....

View 1 Replies View Related

JQuery :: Remote Tab Adds Wrong Url To Embedded List Item Ahref's?

Jan 5, 2010

I have links in my tab panels. Those links are broken because (from what I can figure) the remote tab section in the ui.tabs.js file adds #ui-tabs-(some number) to those links.

var id = self.tabId(a);
a.href = '#' + id;

What can I put in my tab function:

jQuery(document).ready(
function() {
jQuery("#tabs").tabs();

[code]....

View 2 Replies View Related

Vertical Menu - Height Of The Second Level Menu Results In Their Being Gaps In Between Each Menu Item

Jun 3, 2009

The problem is that the height of the second level menu results in their being gaps in between each menu item so that as you move your mouse down the second menu items it quickly closes again. scripting novice fix this by telling me which variable I need to change either in the Java script or the CSS files.

View 2 Replies View Related

HTML Checkbox Adds/subtracts Items In Menu?

Nov 26, 2009

Not sure how easy this is, but I would like to have 4 checkboxes that effect the items shown in a drop down menu.

For example:
[x] School #1
[x] School #2

[code].....

View 11 Replies View Related

How To Make A Simple Select Menu That Adds A Flat Rate Shipping Fee?

Oct 18, 2005

Can someone tell me how to make a javascript that will add a shipping price ($5.00) to any price that is listed as a value for a select menu on multiple drop downs?

<select name="shirt">
<option value="10.00">s-l</option>
<option value="12.00">xl-xxl</option>
</select>

Price: <input type="text" name="total" value="$0.00" /> (would show this without touching the drop down)
Price: <input type="text" name="total" value="$15.00" /> (would show this if selecting s-l)
Price: <input type="text" name="total" value="$17.00" /> (would show this if selecting xl-xxl)

<select name="shorts">
<option value="14.00">s-l</option>
<option value="16.00">xxl-xxl</option>
</select>

Price:
<input type="text" name="total" value="$0.00" /> (would show this without touching the drop down)
Price: <input type="text" name="total" value="$19.00" /> (would show this if selecting s-l)
Price: <input type="text" name="total" value="$21.00" /> (would show this if selecting xl-xxl)

View 5 Replies View Related

Execute Function On Current Item?

Aug 28, 2009

I have this code which removes a class from an item on mouse out.

Code:

function mouseOut8( ) {
$('.bar8')
.removeClass("barover");
}

I would like to change this so that the class is removed from the item I have just moused out of instead of specifying the exact item. This is so I can use this function for multiple items. I tried replacing the '.bar8' with 'this' but it didn't work.

View 2 Replies View Related

JQuery :: Access The Current Item's Attributes?

May 12, 2011

$('td[id=opinionAxis]').html("<img src=images/"+this.attr("title")+".png>");

So essentially what I'm trying to is put an image inside all my td's that have "opinionAxis" as their id. The image has to be equal to the value in the title attribute in addition to the sub folder and file type. How do I access the current item's attributes?

View 2 Replies View Related

Collapsible Menu Code - Clicking On The Menu Item Will Bring Them To The Specific Page?

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

JQuery :: Create A Specific Menu Where Toggle A Clicked Menu Item

Sep 30, 2010

I am trying to create a specific menu using jQuery where i want to toggle a clicked menu item. I used toggleClass to accomplish this. All fine and well, but what i want is that once i click a menu item, the previously clicked item should have the active state/class toggled off.. The menu is variable. (I tried and tried and searched all over the internet, but i cannot find it... spent 5 hours trying to combine various selectors and if/else statements, but it did'nt work.)

View 1 Replies View Related

What Would Be The Best Color To Match If The Menu Background Is Left As It Is When Hovering On A Menu Item

Jun 16, 2011

Am working on a web template similar to this one: [URL] and would like to change the hover color for the menus (in blue with white text). What would be the best color to match if the menu background is left as it is when hovering on a menu item?

View 2 Replies View Related

Drop Down Menu - Over The Sub Menu The Background Image Of The Top Item Disappears

Feb 11, 2011

I'm building a drop down menu like [URL] or [URL] or [URL] the effect I'm trying to achieve is to have the top menu item showing a background image via css and create a stylized design with the sub-menu. Using CSS when I hover over the sub menu the background image of the top item disappears. So I'd like some guidance with javascript on how to keep the back-image while hovering on the sub menu.

View 1 Replies View Related

Jquery :: How To Get Current Item Index In Group Of Elements

Jul 14, 2009

I am trying to find and get the current index in a group of elements like so:
var index = $(attribute).index(this);
However, this returns -1 for all selectors I pass to it in the variable. Why is this? Is there another way to find a div's position within its container easily?

View 2 Replies View Related

Default Selected Item And Field Value

Jul 20, 2005

This is my form, i would like to default the select box to USA, and default
the text field to a name such as 'Sarah' and the hidden field to another
number like ??', when the user clicks on the check box, otherwise the
fields should be blank, the value of the select box dosnt matter much, only
that it defaults to USA, when the user checks it.

--
<form name="form1">
<input type="checkbox" name="checkbox" value="checkbox">

<select name="prefix">
<option value="off" selected>Select country
<option value="61">Australia
<option value="1">USA
<option value="58">Venezuela
</select>

<input type="text" name="name">
<input type="hidden" name="number">
</form>
--

View 3 Replies View Related

Changing Item Selected In A Select Box

Jan 13, 2011

I have a select box, is there a way to get javascript to select an item for me?

Here is my html, can I get javascript to select the option for ray?

View 4 Replies View Related

Change Value Of An Item If A Class Of Another Changes

Jan 7, 2010

I have a drop down menu with a few options of delivery method. One option is "other" and when a user selects other a new text box appears for them to specify. this is using javascript to change the css class of the div containing textbox. all this works fine and user can change between options resulting in textbox appearing when selected other and disappearing when selecting anything else. however if the user selects other and enters text into textbox then chages their mind and selects a new option the textbox will disappear but the value that was entered remains the same, i need to default when textbox is hidden to reset value.

View 4 Replies View Related

JQuery :: Fetching Data Of Selected Item?

Mar 24, 2010

I want that data against each option should be loaded as the option is selected in the combo box. As, while registering on yahoo, when we select a country all provinces of that country are loaded. (No need to click a submit button.)

View 1 Replies View Related

JQuery :: Getting Element ID Of Selected Item In List

Nov 27, 2010

I have a bunch of DIVs (not an <option> List) each of the class "SongListItem". For one of the DIVs at a time, I set a "Selected" attribute, so it sort of acts like a ListBox. So two rows in the list might look like:
<div id="Item1" class="SongListItem">Item 1 Text</div>
<div id="Item2" Selected="True"class="SongListItem">Item2 Text</div>

Now I want to write a jQuery function which gets the ID of the SongListItem div that has Selected="True". So far, I have tried:
var SongID= $('.SongListItem[selected="True"]').attr("id");
and
var SongID= $('.SongListItem[selected="True"]').get(0).attr("id");
In both cases, I get a "Object does not support this method."

View 2 Replies View Related

JQuery :: Triggering A Function When An Item Is Selected?

May 10, 2009

Is it possible to trigger a function that fires when an item is selected from the autocomplete box?

View 1 Replies View Related

JQuery :: Dependent Validation For Selected Item ?

Nov 22, 2011

I am using jquery validate js for my validation. I need to validate and pass the value for the below senario.

I am having a dropdown box which has 2 option. Option 1 and Option 2.

And I have few checkboxes with same name. Depending upon the dropdown selection it should show/hide some checkboxes. Using javascript and CSS these are working fine.

The problem I am having is with the Select All function. If I check Select All it checks the hidden field also. The requirement is to select only the fields which are visible not the hidden one. Please suggest me how to do this.

Example

Here Value 3 and value 4 are common. If I select option Select Item 1 Value 1 will show and value 2 will be hide. If I select all it should not select value 2. As the name is common its selecting that also. It should not select value 2. This is the requirement

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved