JQuery :: On Click Add Class Not Staying Applied

Mar 29, 2010

I'm trying to add am active class to my menu when the link is clicked using the following [code]...

The active class gets applied but them disappears straight away. Is there something I've missed.

View 3 Replies


ADVERTISEMENT

Submenu Staying Open On Menu Click?

Nov 22, 2011

I have a menu with some items containing a submenu. The submenu's should open when a parent is clicked and contains submenu's, and when traveling to another page (from the item clicked, for example a parent of submenu item), the submenu should remain active and visible. When I click on a parent (at the moment the hrefs contain no links just #), the submenu opens. But when I click another main item, the submenu of the previous parent remain visible, and the submenu of the parent just clicked is also visible, while I only want the submenu of the parent clicked to be visible or when parent with no submenu the submenu should be invisible.

So, here is the code I have so far:
Code:
<div id="topnav">
<ul>
<li>
<a href="index.html">Home</a>
[Code]....

View 4 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

Difference Between Class And Name Properties In HTML, As Applied To JavaScript

Dec 17, 2001

how the class attribute works in CSS: I can specify that every attribute with class="foo" be italicized with: .foo {font-style: italic;}

What if I want to do the same sort of thing in Javascript? Is there something built-in like document.GetElementsbyClass("foo").style = "italic" (I'm just making this code up of the top of my head, I don't know how javascript works.)

It seems to me that with JavaScript you're supposed to use the name="" attribute instead of class="". Why the diference?

I looked at webmonkey that had an article about this, but their writing style is simply confusing and I can't make heads or tails of their articles.

View 1 Replies View Related

JQuery :: Click Swap Image Gallery - Turn Off The "hover" Class And The "show" Class Of The Others When You Click One?

Mar 23, 2011

This is what I'm trying to do: I want a simple image container to swap the image inside it by clicking the nav buttons on the right like 1, 2, 3.Here's my code:

HTML
Code HTML4Strict:
<div id="item1">
<div class="img-container shadow" style="background-image:url(images/gallery/tcg1.jpg)">[code].....

My jQuery code is not right. I want it to turn off the "hover" class and the "show" class of the others when you click one. I think I need some kind of if..else? how to write it? I have a bg image set on the container div so there's an initial image to view.I also need multiple of these on the same page!

View 1 Replies View Related

JQuery :: Assigning A Click To A Class Selector - Once Clicked The Class Is Removed - Does This Work

May 5, 2011

I have a huge blob of code but the main part I am focusing on is this

$('.billboard_click').click(function () {
//this remove class
$(".billboard_click").removeClass("billboard_click");
});

1. Execute a click event when the div with the class 'billboard_click' is clicked

2. Once clicked, remove the class from that very div to avoid another click from happening

3. Execute a series of events such as animations, etc

4. add the class back to the clicker div

The code does not seem to work as expected but I am wondering if I am having issues elsewhere at this point and wonder if this actually is known to work

View 7 Replies View Related

Staying Framed

Jul 20, 2005

I have been searching around for a way to ensure a page stays framed.
Here's the catch. The user starts at a two-frame page with the Google
directory in one frame. I want the user to be able to navigate
through the Google directory, but within the frame. Google has some
sort of frame-busting script on this page and I need to find a work
around. The standard,

if (top.location == self.location) {
top.location = 'page.html'
}
script doesn't work because I can't place this script in Google's
page. I have to control it from my pages, either the frameset page or
the other frame.

View 3 Replies View Related

Staying On Same Page Or Moving To Next

Oct 23, 2004

consider the senario for example if i am taking some input from user on my page and checking that the input should be a number for that imake a script shown below which is working fine Code:

View 3 Replies View Related

Second Click Not Working Once Class Is Changed On First Click?

Nov 3, 2011

When I click on a link, I want to remove it's class, then add another link, THEN, when I click on it again, I want to reverse it.

html4strict Code:

Original
- html4strict Code
<a href="#" class='link1'></a>

[code]....

View 3 Replies View Related

JQuery :: Add Or Remove Class On Next Click?

Sep 9, 2011

I am a beginner and would like to know how i can change the class of selected element when clicked, but remove the same class from other element.

For the example

<ul class="items"> This class has some css which includes list-style:none, borders and backgrounds
<li ><aonclick="javascript:changecolor();"> Something 1 </li></a>
<li><aonclick="javascript:changecolor();"> Something 2 </li></a>
<ul>

The jquery function is an external file and I also have .color which changes the background of a <li> item...

So what i am trying to achieve is that when "something 1" is clicked i want to get the class .color to this list item "1" for example, but when "something 2" is clicked i want the class .color to move on this li item "2", but list item 1 should not have the class .color at the same time..

View 6 Replies View Related

JQuery :: Click On Div Class Not Working

Jul 18, 2011

Im trying to make divs with diferent classes for each element this way (rails 3)

This give me this HTML code:

But is not working.

View 1 Replies View Related

JQuery :: Can't Have Click On Multiple Items With Same Class?

Oct 14, 2010

I'm trying to have multiple divs with the same class acting a s a button. I need to handle the click for each one. I will be obtaining the name attribute and passing that in an ajax call.However, this only works for one of the divs on the page, am I doing something wrong?

$(document).ready(function(){
$('#mark_sold').click(function() {
var item = $(this).attr("name");
alert(item+'clicked');
});
});

I'm also going to need to know how to refresh an image, too. I will be updating an image in the ajax call.

View 2 Replies View Related

JQuery :: Change Class Of Li On Click Of Input?

Jun 9, 2010

I have an input inside an li

<ul class="action">
<li class="warning">
<label for="ESig" class="tall">Name</label>
<input name="ESig" type="text" class="swap_value" id="sig" value="Electronic Signature Required" />
</li>
</ul>

when you click inside the input #sig, I need the parent li's class to change from "warning" to" (they have different bg images)

[Code]...

View 2 Replies View Related

JQuery :: Get Index Of Same Class Element On Click?

Jul 22, 2011

I have many small divs which have a particular class. so based on this class only i am getting the click event on them. now what I want is to get the index of one single div one which we clicked.. I am not remembering how to do it..

View 9 Replies View Related

JQuery :: Select Next Class From The Point Of Click?

Sep 19, 2010

in FCK-Editor I would like to do the following:On one page there should be severalHeaderText under the header, which is hidden, when the text is loaded and slides up and down after click on headerHtml, which is easy to edit with FCK could look like this:

<p><a href=""><span class="click">Header</span></a></p>
<p><span class="text">Text under the header, which is hidden, when the text is loaded.</span></p>

[code]....

View 7 Replies View Related

JQuery :: Click Event On Nested Elements With Same Class?

Mar 1, 2011

I am making a system whereby if an element has a class "editable", you can click it and a popup box appears with some options about that particular element. Fairly straightforward, I'm using [code]...

This works fine but I need to be able to have lots of different divs, all with class "editable", some of which are inside others with class "editable". Like this [code]...

However, clicking on the 'somethingelse' div, triggers the click correctly but also triggers it for the parent 'something' div, so I end up with the popup box appearing twice.

Does anyone know how to just catch a click event on the exact div (without using ids) without triggering the parent?

View 1 Replies View Related

JQuery :: Not Picking Up Class-referenced Click Function

Oct 26, 2010

I'm new to jquery, and I'm trying to use multiple dynamically generated buttons (removal from a list), that look like this:

<div> item #1 <input type="submit" name="remove_mailinglist_1" id="remove_mailinglist_1" value="Remove" class="remove_mailinglist"> </div>
<div> item #2 <input type="submit" name="remove_mailinglist_2" id="remove_mailinglist_2" value="Remove" class="remove_mailinglist"> </div>

[Code]......

Three quick questions:

1. Why might this function not get triggered? (I set a breakpoint and it never makes it into the click function.)

2. How could I tell which "Remove" button was pushed? Where can I find the data in scope?

3. Is there a more standardized way to do what I'm doing?

View 2 Replies View Related

JQuery :: Goes To The Save_edits Page Instead Of Just Using The Post And Staying On The Original Page - Mozilla Not Working

Apr 12, 2011

I have the following bit of jQuery:

Code:
$("#save_photos_all_continue").click(function() {
event.preventDefault();
var $black_white_all = $("#black_white_all").is(':checked');
var $color_all = $("#color_all").is(':checked');
var $other_all = $("#other_all").is(':checked');
[Code]...

In Google Chrome it works fine but in Mozilla/5.0 it actually goes to the save_edits page instead of just using the post and staying on the original page.

View 2 Replies View Related

JQuery :: Highlight Sentence On Hover - Change Class On Click

Sep 5, 2009

I'm trying to figure this out with jQuery: I have a few paragraphs of text kind of like this:

<p class="original" id="paragraph_1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce ut metus augue, vitae malesuada massa. Vestibulum nec lectus urna, vehicula porta leo. Fusce dui nunc, scelerisque at molestie ut, ultricies eu purus. Duis tristique placerat rhoncus. Aliquam rhoncus lacus justo. Morbi ultricies egestas orci eget fermentum. Proin sapien sem, suscipit vel semper in, tincidunt id enim. </p>

<p class="text" id="paragraph_2">Maecenas nisl ipsum, faucibus sed pulvinar a, tristique sed magna. Sed dui erat, tempor ut rhoncus sagittis, lacinia quis lorem. Quisque feugiat, ipsum nec varius elementum, est nunc lacinia mi, mollis convallis lorem ipsum at erat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>

And I have a couple of classes, like so:
.highlight {
background-color: #ccc;
} .strikethrough {
text-decoration: line-through;
}
What I want to do is apply the .highlight class to a sentence (not the entire paragraph) on hover, and apply the .strikethrough class to a sentence on click. It's easy to find a sentence using regex, but I don't know how to add/remove a span to just that particular sentence that is being hovered over. I know I could programatically wrap each sentence in <span>...</span> tags on the backend, but I was hoping there was a better solution.

View 1 Replies View Related

JQuery :: Cancel Class Not Working For SubmitHandler To Ignore Button Click?

May 4, 2011

Go these two image buttons:

<input type="image" src="images/Update.png" name="btnSubmit" value="Update"/>
<input type="image" src="images/Cancel.png" value="Cancel" name="btnCancel" class="cancel" onclick="hide_edit_div()" />

Now, even clicking on the Cancel button runs the submithandler. How do I modify it to ignore it?

[Code]...

View 1 Replies View Related

JQuery :: Can't Apply Css - It Gets Applied, But Then It Gets Overwritten

Mar 12, 2011

If you try out the code, you will see 2 buttons. Either button downloads content into the page using ".Load". You can try clicking on either or both buttons. The problem is that I want the color of loaded content to match the color of the button. To do this, I set the css of the loaded content to be that color. This works very briefly, and then its covered up again by the default color, which is black. It is as if the browser loads content, applied my css from my css code, and then makes another pass and applies the default css. But of course Idon't know for surewhat the browser is doing. So there are 3 web pages here. The first is the webpage that has the code. The other two are webpages have the paragraphs that he first page loads. The names of the pages are listed: So voila - first page (name is demoProblem.htm).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-type" content="text/html; charset=windows-1252" />
<title>Course page</title>

[Code]......

View 2 Replies View Related

JQuery :: Ui Autocomplete Style Not Getting Applied?

Oct 23, 2011

I'm trying to implement my first jQuery UI combobox. I have the data displaying and filtering as expected. However, the expected style doesn't seem to be getting applied. configuration or restrictions for trying to implement this? Do I have to specify a "class" or is it possible to just specify a "style" for the control?

View 1 Replies View Related

JQuery :: Easing Be Applied To Addclass Animations?

Sep 21, 2010

i have in place an fade in application of addclass to a selector but i would like the transition to use one of the easing plugin equations instead for more dynamism. I can't tell how i would do this, since all the examples only use the animate function.

View 1 Replies View Related

JQuery :: Ignore Applied Actions With Certain Classes?

May 21, 2011

<div class="one">
Text here
Text here
<div class="ignore">Text here to remain black</div>
Text here
Text here

[Code]...

My question is, how would I change all text within class one to say red (including sub-divs/spans etc), whilst completely ignoring the text with the ignore class(es)?

View 3 Replies View Related

JQuery :: Plugins Aren't Applied On Second Call?

Jun 8, 2009

i've been having an issue with the jPicker and jquerySpinButton plugins. if i apply each plugin to one instance (say, a span) they work fine. however, the next time I do the call, the elements are not modified by the plugin. on the demo page, there should be two spin boxes, and two color selectors. only the top 2 work, the bottom 2 are deformed.[URL]..

View 2 Replies View Related

JQuery :: A New Loaded Html Elements Can't Be Applied Function?

Apr 4, 2011

I already make this line of code

$('#bank').click(function(event){
// request form
$('#middle').load('form/bank.html');
$('#butang').click(function(){

[Code].....

Which means, once after a link namely as "bank" is clicked,then it will extract the bank.html contentinto the middle div. And I already put a button ID named as "butang" over that bank.html. But why after the content is nicely rendered, I can't obtain the alert?

Hmmm... even when I clicking, clicking, and clicking many times at the button named as "butang", can not also give me an alert. How could I apply a jquery into a new html rendered as it firstly it's not there?

View 3 Replies View Related







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