Onclick Change Class, Remove When Next Link Clicked?

Dec 3, 2007

I have a side menu that I have added an onclick statement to, which will change the css class for that item to "selected" so that I can apply styles for the selected link. Here is what I have:


HTML Code:
<style type="text/css">
<!--
.selected {[code]....

How can I modify this so, after one selection is clicked, and you click something else, the class gets removed from the first clicked item, and is now applied to the newly clicked item? I only want the class applied to the currently clicked item, and removed when they click on another item.

View 14 Replies


ADVERTISEMENT

Remove/add Link Class When Clicked?

Mar 8, 2007

I am on a tight deadline with none of my Javascript books around to reference ... Can anyone help me with this script:

View 13 Replies View Related

JQuery :: HasClass / RemoveClass Bug - Set Add / Remove A Class Called 'active' To / From A Link That Is Clicked Within A DIV

Sep 12, 2011

I have a link as such:

[Code]...

In a nutshell, I need to set add/remove a class called 'active' to/from a link that is clicked within a DIV. So if the link has the class 'active' already assigned I need to remove it and vice versa however the issue I am having is that I have to double click the link in order for it to work!!

View 6 Replies View Related

JQuery :: Getting Div Class Near Clicked Link?

Jan 25, 2011

Lets say I have a function that is going to be called when a link is clicked like so:

<a href="javascript:someFunction();" >Click me</a>
<script type="text/javascript">
function someFunction()

[code]....

View 2 Replies View Related

JQuery :: Retain A Class After A Link Is Clicked - For Pseudo Checkboxes?

Nov 23, 2010

I'm creating a list of items which visually look like checkboxes. They will work similar to the ones used on eBay that allow you to select only new/used items. Mine are a little simpler though. Here is the markup:

<li>
<a href="#" class="catHeader trigger">Designers</a>
<ul class="nav-ul toggle_comtainer">

[code]....

View 3 Replies View Related

JQuery :: Getting A Selector Working - Expect The Class Of 'testclass' To Be Applied To The Button After The Link Is Clicked

Feb 7, 2010

I'm having trouble getting a selector working. Probably best just to give you some example code:

HTML
<input type='button' class='test' value='Button Name'>
<div>
<a href='' class='buttonLink' />Click me</a>
</div>
Jquery
$(.buttonLink).click(function() { $(this).closest(':button.test').addClass('testclass'); });

Form that code I would expect the class of 'testclass' to be applied to the button after the link is clicked, but It doesn't seem to work. This is a somewhat contrived example. In my real application I have a form with several collapsable/expandable sections. If the fields in those form sections have values when the page loads, the section needs to be expanded, and the expand/collapse button needs to have a class of 'expaned' applied to it, if not it needs to be hidden. I can check the form fields and show the div if needed without any problem, but I can't seem to figure out how to work out the selector so I can add the class to the button.

View 7 Replies View Related

Spot Syntax / Logic Mistake - Should Open A Modal Everytime A Link Of A Given Class Is Clicked

Jul 29, 2009

It should open a modal everytime a link of a given class is clicked. But... it does not.

Code JavaScript:
//get the url of the link clicked
var url;
$('a.edit').livequery('click',function(){
url= $(this).attr('href');
});
[Code]....

When a link of class .edit is clicked, the overlay covers the page for an instant, then a redirect occurs to the page that should be loaded in the modal box (instead of the page being loaded in the modal). It's probably a small mistake as I can get it working the way I want using jqm 'trigger:a.edit'. The problem with this approach is that I lose the livequery power (links from ajax loaded content won't fire jqm).

View 5 Replies View Related

Change The Color Of A Link After It Has Been Clicked On WITHOUT Using CSS

Aug 22, 2009

I am trying to change the color of a link after it has been clicked on WITHOUT using CSS.

When the link is clicked some javascript is called. I can do this in IE by adding this "this.style.color = 'black'". However this doesn't work in other browsers. Anyone know how I could get this to work in other browsers?

View 2 Replies View Related

Change Image Of Link After Being Clicked On?

Sep 10, 2010

I read some other threads regarding how to toggle an image but I was having a hard time understanding. I have a bunch of images on my page, each links to a different lytebox presentation when you click on them. I'd like to have the clickable image change to another image to indicate to the user that they have viewed that presentation. I was hoping there was a way to switch to the new image permanently rather than just toggling back and forth between the two images if they click on the presentation more than once.

View 6 Replies View Related

Change Image After Link Has Been Clicked On?

Oct 23, 2010

i want to make a facebook fan page and iam using fbml to do this. i want to change the original image once a member likes the page.

View 1 Replies View Related

Image Change When A Link Is Clicked?

Feb 20, 2011

I have created a site http:[url].... and there is an image on the page which I want to change if a user clicks on a link. I am not sure if javascript is the best way to do this but thought i would give it a go. The image is currently set in the css so I think i will need to change this to use js?

View 1 Replies View Related

How To Make A Link Image Change When Clicked?

May 4, 2003

I am working on a explorer like tree in a php script. I have the standard + - in a box pics. How to I have the + pic change to the - pic when clicked. Also, how do I get it to change back when another + pic is chosen?

View 16 Replies View Related

JQuery :: Change Css Class Onclick?

Aug 27, 2009

I have a set of links in a named div. each link has a specific css classname to emulate a button. Basic css menu thingy.

<div id="buttonwrapper" class="buttonwrapper">
<a id='one' class="squarebutton" href="#" onclick="javascript:dosomething('one')" style="margin-left: 6px"><span>ONE</span></a>
<a id='two' class="squarebutton" href="#" onclick="javascript:dosomething('two')" style="margin-left: 6px"><span>Two</span></a>

[Code]....

View 4 Replies View Related

Change Css Class OnClick With Fade?

Feb 4, 2010

is it possible to change the class of an element onClick with a fade? This is the code I have so far which works great for changing the class but I have no idea how to include a fade in this. I am changing the class in order to change the background-image of a div.

<a href="#none" onclick="document.getElementById('tool').className ='tool1'">

View 2 Replies View Related

JQuery :: Change Mouse Pointer When A Link Is Clicked?

Jan 15, 2011

I'm making a webpage for a little embedded device with a touch screen. I don't want the mouse pointer to be visible until the user clicks on a link in which case the mouse pointer should change to an hour glass until the new page is displayed (the device is rather slow so the user needs to get some feedback while waiting). code...

This properly hides the cursor after the first page is loaded but it doesn't display the hour glass when I click on the link. Any ideas what I'm doing wrong?

View 1 Replies View Related

JQuery :: When A Link Is Clicked That It Will Only Change Elements That Are Within It's Parent Div And Not The Others?

May 27, 2010

I have several divs that each have a certain link. How can I make sure that when a link is clicked that it will only change elements that are within it's parent div and not the others?

View 1 Replies View Related

JQuery :: Change A Css Class OnClick With Fade?

Feb 4, 2010

More of a javascript question than specifically jquery but I was wondering how to change a css class onClick with a fade?

This is the code I have so far that is working fine to change the class but I don't know how to allow this class to fade in or even if it's possible?

View 1 Replies View Related

JQuery :: Change Class Onclick From Account To Account_selected ?

Jun 8, 2009

I have this code:

This is changing my class name from account to account_selected, which is great but what I need it to do is when another div is clicked is change the class back to "account" and set the one that was clicked to "account_selected."

View 4 Replies View Related

Running OnClick To Change Href Class CSS Style

Jan 12, 2010

I am using this javascript code to run 'onclick' to change my href class style. It works to change the style, but when I click on the next menu item, the previous one is not reverted back to how it was previously, but the formatting is stripped away leaving the link purple with no background image. How do I get it to revert to the original class which is set?

Here is the javascript :-
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
var Lst;
function CngClass(obj){
if (Lst) Lst.className='';
obj.className='menu1';
Lst=obj;
}
/*]]>*/
</script>

Here is the relevant CSS :-
.menu {
background: url('../images/productblack.jpg') repeat;
width: 100%;
line-height: 24px;
float:left;
display:inline;
font-family: Verdana;
color : #ffffff;
font-size: 8pt;
text-decoration: none;
text-align: left;
font-weight:bold;
} .....

Here is the HTML :-
<div id="masterdiv">
<div onclick="SwitchMenu('sub1')"><a class="menu" onclick="CngClass(this);" href="javascript:nothing()"> 
RESISTORS</a></div>
<span class="submenu" id="sub1">
<a class="productsubmenu" href="resistors.html">Surface Mount</a><br> .....
Here is a working page with it (the product menu on the right) [URL]

View 2 Replies View Related

Onclick For Div Background Change And Link To Iframe?

Feb 2, 2010

I just cannot get the html to load for each linked button to the Iframe. If I remove the "onclick" command for the backround images, the links load to the Iframe. If I leave the "onclick" command in there only the background changes.So, I would assume there is a conflicting issue with loading the "a href" and the "onclick" commands together. Maybe I need to know how to do multiple "onclick" commands...suggestions?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

[code]....

View 2 Replies View Related

Onclick Link Change Text Color ?

Aug 11, 2011

I have a page here [url]. What I want to control is that for link on the left that is clicked I want the text to change to a particular color to highlighted it have been selected. And when another linked is clicked I want the previous linked to be reset to the normal color. How to achieve that.

View 2 Replies View Related

Onclick Link Change Text Color

Aug 11, 2011

I have a page here [url]. What I want to control is that for link on the left that is clicked I want the text to change to a particular color to highlighted it have been selected. And when another linked is clicked I want the previous linked to be reset to the normal color.

View 4 Replies View Related

Change Link URLs With Text OnClick

Sep 27, 2011

Any way to update URLs on a page depending on the region selected by the user. I have 3 regions, Americas, Europe & Asia. And depending on the region selected I need to update URLs on the page for the different regions.

For example, below are the 3 possibilities for the links.
domain.com/americas/product.php
domain.com/asia/product.php
domain.com/europe/product.php

View 8 Replies View Related

Change The Background-color Of The Link Onclick?

Oct 11, 2011

l have got a series of menus. What l want to do is change the background-color of the link onclick.

What l have done use jquery like this

jQuery('.menu a').click(function(){
var clz = jQuery(this).attr('id');
jQuery(this).attr('class','active'+clz);
})

This is not work.The code needs to work on mobile phones

View 3 Replies View Related

Change Text Color Of A Link With Onclick Event

Jul 20, 2005

I created 3 hyperlinks, when the user click each link, it will change
the color of the text of a link. For example, when user clicks Link1,
text Link1 will become red color, but Link2 and Link3 unchange. Here's
my attempts, any ideas??

<script language="javascript">
function changecolor (i)
{
document.i.fontcolor = red;
}
</script></head><a name="item1" href="test.html"
onClick='changecolor(item1)'>Link 1</a><a name="item2"
href="test.html" onclick='changecolor(item2)'>Link 2</a><a
name="item3" href="test.html" onclick='changecolor(item3)'>Link 3</a>

View 5 Replies View Related

JQuery :: Select Class Which Is In The Same Class Of Class, On Which Clicked?

Jun 3, 2010

My code: [URL]... When I click on Upraviť in class edit I need add some HTML code to begin and to end of class entry how to I can select class entry in the same class post on which I clicked?

View 1 Replies View Related







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