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


ADVERTISEMENT

JQuery :: Click On And Highlight Nested Elements Independently?

Jul 22, 2011

I want to find a way to highlight elements when I click on them. The problem is the elements are nested and when I click on a child element, the parent element is highlighted as well. I would like the child to highlight only, but because the child is within the boundaries of the parent (i.e. you can't hover over the child without also hovering over the parent), the parent highlights as well.

For example, if you have...

<div>
<h1></h1>
<ul>
<li></li>
<li></li>
</ul>
</div>

I'd like to be able to hover over, click and highlight an <li> and hover over, click and highlight the <div> independently of one another. It's no problem to hover over, click and highlight the <div> without highlighting the <li>, but because the <div> encapsulates the <li> it's impossible to hover over, click and highlight the <li> without highlighting the <div>.

View 1 Replies View Related

Why Return False Stop Event Handlers To Run On Nested Elements

Oct 23, 2009

I have nested markup like this
Code HTML4Strict:
<li><span></span></li>
I have different click functions, one attached to the li and the other to the span.

When I click on the span they both run. Ending the span's event handler with return false; prevented that from happening, which is what I want. But I'm not sure I understand why it worked.. I know, for example, if I was clicking on an anchor, return false would stop the browsers default action of following the href value. Same for submitting a form, return false will stop this. I don't think I understand why this would stop a completely different function from being triggered..

View 7 Replies View Related

JQuery :: Select Box Calling Another Elements Click Event 1.4?

Feb 4, 2010

I have a div on my page witch is hidden : AddSupplier, I have a button on my page witch must show the div if its not visible, but the same button saves some stuff if the div is visible.So all that is working but in this AddSupplier div there is a select box "ddSupplierTypes" and when the select box gets clicked the AddSupplierButton click event gets triggered why is this, and is there a work around?

<%@ Page Language="C#" %>
$
().

[code]....

View 1 Replies View Related

Can't Set Event Listeners To Multiple Elements Of Same Class

Dec 3, 2009

I'm trying to add event listeners to multiple elements of the same class. The DOM is something like this [code]...

View 5 Replies View Related

JQuery :: Click Event Not Firing When Attached To Elements That Are Inside Of The Hidden Element When The Page Loads?

Mar 31, 2010

i am working on a custom drop down list that has hidden #options DIV which is shown when the user clicks on a button. the problem i am having is that the click event does not seem to be attached to the LI elements since they are hidden when the page first loads. if i show the #options DIV when the page loads everything is working as expected.i've tried to attach the click event after i show the hidden UL but that didn't work either.what can i do to make sure the LI click event fires? i tried to put A tag inside of LI and attach click to that but to no avail.

<style type="text/css">
.gbtn-options {
overflow-y:auto;[code]....

View 6 Replies View Related

JQuery :: Insert Class Into Td In A Nested Div?

May 14, 2009

I have a series of td's that reside within a nested div. the <td> has no class value and I would like to inject a css class value.

<div class=x>
<div class=y>
<div class=z>
<table><tr>
<td>x</td> want a class in these tds

how can I do this with jquery?

View 1 Replies View Related

JQuery :: Events/live And Default - Method To Bind A Handler To A Click-event For All Links With Class "userDiv"

Jun 10, 2009

I use the live - method to bind a handler to a click-event for all links with class "userDiv"

When I DON'T use this and use instead the "normal" click handler

I can still use the middle Mouse-Button in Firefox to open the link in a new tab without any jquery-stuff

But when I use the live-method (and it would be nice to use it) the middle Mouse-Button behaves like the left one.

View 2 Replies View Related

JQuery :: Selecting Nested Elements?

Aug 17, 2011

i'm trying to do the following: select the links one after another and add a class to them. When the next one is selected i want to remove the class from the previous.

[Code]...

View 4 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 :: Targeting Specific Nested Elements Of $(this) Efficiently?

Nov 24, 2010

My HTML:

<div class="home-button">
<span><a href="#" style="">Button</a></span>
</div>

I have an instance of a div (button), inside this div is a link wrapped in a span. When you hover over the div (".home-button")I want to move the background position inside its "span a", I've achieved this using the code below.

[Code]...

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

JQuery :: XML Looping Through Nested XML Document And Updating Page Elements Dynamically With XML Data?

Jan 26, 2010

I have created two onClick events that i need to combine into one with jQuery. I am not sure how to do this.I have an unordered list:

<ul id="coverTabs">
<li class="currentTab"><a href="#">Individual</a></li>
<li><a href="#">Couple</a></li>

[code].....

View 1 Replies View Related

JQuery :: Handling .hover Event With Nested List?

Nov 17, 2011

I have a nested lists. I'm using hover event to trigger an event. But when I hover child nodes, the event of theancestor list is being fired. How can I get rid of this situation

View 1 Replies View Related

JQuery :: Live() Event Doesn't Refresh The Class Of The Event Which Was Changed Dynamically

Jul 4, 2009

I got this problem with live() event.I have used it as follows.

$(".addressDiv span").live("mouseover", function(){
//clickable function here......
------------------------
});

I have used the live() event to trigger the function on mouseover in the dynamically added elements. But the problem i got is that once the live event is called it takes the class of the element and stores. And when the class of that particular element is changed dynamically the live() event does not detect the new classed added dynamically, instead it takes the former class. Live() event does not update the class.

View 3 Replies View Related

Absolute Positioning Of Nested Elements

Oct 9, 2009

I am working on a puzzle that produces a container div.Within that div are produced a grid of 9.16. or 25 tiles.The tiles are positioned absolutely so I can be sure of their relative placement. The container div width and height is calculated according to a preset tile width and height (square actually). So the width of the container should adjust to either 3,4 or 5 tile widths and heights.The trouble is that the offset position of the top left tile is different relative to the container for each different set of tiles (even though it is supposed to be the same position relative to the container for each). I do this so I can apply dragging to the container div.The tiles will follow the container when it is moved and the game will not loose its place when tiles swap locations.(one tile is elected as blank, and tiles, one to left, right, top
or bottm, with game content, will swap location with blank when clicked)

View 5 Replies View Related

JQuery :: Stopping A Click Event With Another Click Event?

Nov 23, 2010

I would like to create a plugin that I can put before a click event on a button. The click event should occur if the user's time on the page hasn't expired. The plugin should check the user's time, and then stop the click event if the time has expired. With the plugin, I'm essentially putting two click events on the same button, as I need to check the expiration when the button is clicked. The plugin is working on my test page, but I'm afraid that this is contingent on an arbitrary ordering of the click events by jQuery. If I have my click event chained after my plugin, can I be assured that the plugin would always stop the click event if the time is expired? Or could jQuery execute the click event before the time gets checked?

(function( $ ){
$.fn.checkExpiration = function(
$this = $(this);
return this.each(function(){3

[Code].....

View 3 Replies View Related

Event Handling And Nested Div

Jan 20, 2008

I have two div elements (both dynamically created, one within the other). The parent div has an event attached to it:

contextmenuDIV.onmouseout = function () {doSomething()}

for example. However the onmouseout event will fire when you mouseover the child div as (of course) I am technically leaving the div layer (despite it being the parent).

Is there anyway to cancel this? I've read all about bubbling and all that, but it's just confusing me even more!

Anyway, at all, to allow me to have divs within another div element but only allow the event to fire for the parent!

View 2 Replies View Related

Remove Onclick Event From Checkbox Nested Within H2?

Jul 10, 2010

I have the following javascript for an 'accordian' style html widget.

Code:
var accordionItems = new Array();
function init(id) {
// Grab the accordion items from the page

[Code].....

I have nested checkboxes within each <h2> but I need them to behave independently of the onclick event that is set to the <h2> in the javascript.

In other words, when I select a checkbox, I don't want the onlick event to trigger.

View 1 Replies View Related

JQuery :: How To Get All Elements Of Class

Jun 29, 2011

i want to get all element id's with class name=TestDiv how i can do this? Quick response is needed sample code is below :

[Code]...

View 4 Replies View Related

JQuery :: Click On A Link Just Created Using Click Event?

May 31, 2010

How can I give a click on a link when it is just created and added to DOM?

None of this works:
function openProfilePage(profile){
$('#profile-link').remove();
var link = $('<a/>').attr({'href':'profile.php?user='+profile, 'target':'_blank', 'id':'profile-link'}).css({'top':'-200px','left':'-300px', 'position':'absolute'}).html(profile);

[Code]...

View 7 Replies View Related

JQuery :: Triggering A Click Event Via (event.button != 0)?

Apr 8, 2010

I have an object that has a click event I'm trying to trigger. However in the click event I have the following if statement:

if(event.button != 0){return true;}

This if statement allows right clicks to go through and activate but it also prevents me from triggering the event. Any ideas on how to prevent this? If I remove the if statement from the first click function everything works as intended.Here's my example code based off of the trigger event examples:

<!DOCTYPE html>
<html>
<head>

[code]....

View 5 Replies View Related

JQuery :: Can't Select All 'li' Elements Without One Who's Have Class?

Feb 22, 2010

There is simple html like this:

<ul id="icons">
<li class="icon1 hoverNow"><img src="some/pic1.jpg"/></li>
<li class="icon2"><img src="some/pic2.jpg"/></li>
<li class="icon3"><img src="some/pic3.jpg"/></li>
<li class="icon4"><img src="some/pic4.jpg"/></li>
</ul>

where class 'hoverNow' means, that opacity of the image is 1.0, while others 0.5. This done with css.
i want to do, that when mouse hover the 'li' element, image, IF it's not in the li element, who's having class 'hoverNow', become with opacity 1.0, and on mouseover, again will have 0.5 opacity. For this, i write this simple code:

[Code]...

View 1 Replies View Related

JQuery :: Add Class To All Form Elements?

Jun 1, 2009

I have a form that has it's HTML inserted into the database (yeah yeahI know..not my idea..I'm new here and just finding this out).Anyway, each form field has an embedded class in the HTML.The form is dynamically generated. Can be anywhere from 5 to 10 to 20to 50 fields.How can I loop over each form field and add a new class to the field

View 8 Replies View Related

JQuery :: .append Various Elements Of A Class?

Aug 26, 2009

I'm trying to do the following:

$(document).ready(function(){
img=$(".img");
imga=img.attr("href");
$("#imgbox").append("<img src='"+imga+"'/

View 2 Replies View Related

JQuery :: Match Elements With The Same Class?

Sep 10, 2010

I need to match an h3 with a p that has the same class. However, there are multiple elements and multiple classes, so I'm trying to store the class in a variable (x) and say "when I hover over the h3 with class x, get the p with class x and fade it in".

I can't seem to get it.

View 3 Replies View Related







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