Is it possible, with JQuery to get only one specific element ancestor ?
For example :
<div>
<ul id="tree">
<li><a>Item 1</a>
<ul id="subTree">
<li><a>Item 1.1</a></li>
</ul>
</li>
</ul>
</div>
$('ul li a').click( function() {
// get first UL here
} );
That is, if I click on "item 1" I want to get the "tree" DOMelement,
and when I click on "item 1.1" I want to get the "subTree" DOMelement
only. How can this be achieved ? 4 8019
Yanick wrote:
Is it possible, with JQuery to get only one specific element ancestor ?
For example :
<div>
<ul id="tree">
<li><a>Item 1</a>
<ul id="subTree">
<li><a>Item 1.1</a></li>
</ul>
</li>
</ul>
</div>
$('ul li a').click( function() {
// get first UL here
} );
That is, if I click on "item 1" I want to get the "tree" DOMelement,
and when I click on "item 1.1" I want to get the "subTree" DOMelement
only. How can this be achieved ?
I should specify : I would rather like to avoid
$(this).parent( ).parent() or similar syntax, and would prefer use
something like $(this).ancesto rs('ul')[0] or something.
Yanick wrote:
Is it possible, with JQuery to get only one specific element ancestor ?
If no one here has an answer you will probably have better luck with
the jquery mailing list
<URL: http://jquery.com/discuss/>
Peter
Peter Michaux wrote:
Yanick wrote:
>Is it possible, with JQuery to get only one specific element ancestor ?
If no one here has an answer you will probably have better luck with
the jquery mailing list
<URL: http://jquery.com/discuss/>
I would suggest that the luck would be better there in any circumstance.
The JQuery community is extremely helpful, and generally very quick to
respond.
Web-based access to the JQuery list (via Nabble): http://www.nabble.com/JQuery-f15494.html
--
*** Remove the DELETE from my address to reply ***
=============== =============== =============== =========
Kevin Scholl http://www.ksscholl.com/ ks*****@comcast .DELETE.net
------------------------------------------------------
Information Architecture, Web Design and Development
------------------------------------------------------
We are the music makers, and we are the dreamers of
the dreams...
=============== =============== =============== =========
Kevin Scholl wrote:
Peter Michaux wrote:
Yanick wrote:
Is it possible, with JQuery to get only one specific element ancestor ?
If no one here has an answer you will probably have better luck with
the jquery mailing list
<URL: http://jquery.com/discuss/>
I would suggest that the luck would be better there in any circumstance.
The JQuery community is extremely helpful, and generally very quick to
respond.
Web-based access to the JQuery list (via Nabble):
http://www.nabble.com/JQuery-f15494.html
--
Thanks to you both. I found this :
$(this).parents ('ul:first')
I guess it's the most simple way to get this.
Cheers.
>
*** Remove the DELETE from my address to reply ***
=============== =============== =============== =========
Kevin Scholl http://www.ksscholl.com/ ks*****@comcast .DELETE.net
------------------------------------------------------
Information Architecture, Web Design and Development
------------------------------------------------------
We are the music makers, and we are the dreamers of
the dreams...
=============== =============== =============== =========
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: yurick |
last post by:
Hello everybody,
I'm quit newbie to XML/XSLT, would appreciate any help.
There is XML like this:
<person name="adam"/>
<person name="eve"/>
<person name="cain">
<parent name="adam"/>
|
by: Gale |
last post by:
I'm working on something in jQuery with XPath
What I want to do is: if checkbox is checked, set background color od
label that contain input(checkbox) to red
I have this code:
$("label]").css("background", "red");
but it doesn't working because of nested brackets ] and it freeze
the browser
|
by: DuaneMoraes |
last post by:
A new book on jQuery, the powerful JavaScript library, has been announced by Packt In Learning jQuery, Karl Swedberg and Jonathan Chaffer, creators of the popular jQuery learning resource www.LearningjQuery.com, share their knowledge, experience, and enthusiasm about jQuery to help users get the most from the library and to make their web applications shine.
jQuery is a powerful JavaScript library that can enhance websites regardless of the...
|
by: mikeh3275 |
last post by:
I'm new to developing in jQuery, so I'm probably doing this wrong. I'm loading a form into a modal dialog box and I'm trying to assign a click event to the button in the form, but I can't seem to get anything to happen. Below is the code. Thanks in advance.
jQuery:
jQuery(document).ready(function()
{
jQuery("a").click(function()
{
jQuery("#dialog").dialog({
modal: true,
|
by: Aaron Gray |
last post by:
There does not seem too be anyway to test if two jQuery references are the
same element.
Given :-
... <div id="1"></div ....
Then :-
alert( $("#1") == $("#1"))
| |
by: RobG |
last post by:
Do some of the regulars here need to re-think their (sometimes
strident) opposition to libraries? Both Microsoft and Nokia have
announced support for jQuery.
It seems to have gained quite a bit of momentum, can it be considered
a reasonable choice for those who want to use a full-featured, well
supported library?
<URL: http://jquery.com/blog/2008/09/28/jquery-microsoft-nokia/ >
|
by: souporpower |
last post by:
Hi All
I am trying to print some HTML using JQUERY. I am posting the code. I
don't
see the alert. It seems as though the function is not registered when
the
document is loaded. Can someone please clarify what I am doing wrong?
BTW, I am using IE8 and Chrome to test. Sorry I can't place the code
in a web site.
Thanks for your help
|
by: souporpower |
last post by:
Hello All
I am trying to activate a link using Jquery. Here is my code;
<html>
<head>
<script type="text/javascript" src="../../resources/js/
jquery-1.2.6.js"</script>
<script language="javascript" type="text/javascript">
|
by: jrod11 |
last post by:
hi,
I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes.
There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)?
Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html
Here is some jquery js that I think...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |