JQuery :: Get Attribute Of The Parent Element Into A Variable?

May 8, 2009

but having fun with it. Would like tolearn how to do the following...2) Find the parent <li>.3) Grab the value of the attribute "jcarouselindex" and put it in avariable to be used elsewhere.Sample code below...

<ul id="carousel">
<li class="carousel-item" jcarouselindex="1">
<a href="/someurl"><img src="someimage.jpg" alt="" />

[code]....

View 1 Replies


ADVERTISEMENT

JQuery :: Way To Highlight Element Inside Parent Element / When Mouse Hovers Over Child Element?

Oct 4, 2010

i have a menu generated by a list with nested lists. i want the parent link to stay highlighted when the mouse hovers over the sub menus. because those sub menus are also generated by jquery (qtip), CSS alone won't do it (triedul.topnav li:hover a {background-color: #F00;}).is there a way to do this using jquery?

View 15 Replies View Related

JQuery :: Element Overflows Containing Block When Parent Border/padding Change - Not When Parent's Margin Changes

Sep 24, 2011

Demonstration page: [url]

Adjust the CSS margins of the BODY element with the first slider. The yellow P (paragraph) element resizes to fit its smaller containing block, as I would expect.

Then, adjust the CSS border or padding of the BODY element with the second and third sliders. The P element does not resize, though its origin changes. Instead, it overflows its containing block.

Finally, adjust the margins again. The P element snaps back into its containing block.

As you can see from the source, this is jQuery 1.6.4 and jQueryUI 1.8 pulled from googleapis.com.

Edit: Client is Google Chrome16.0.889.0 dev-m.

View 2 Replies View Related

JQuery :: Get Value Of Custom Attribute From Parent

May 14, 2009

I have been learning jQuery and have been loving it so far. But can't figure out how to do the following...
1) Find the <a> inside a <ul> that has an active class.
2) Grab the value from the parent <li> and put it into a variable to be used elsewhere.

Here is the example markup...
<ul id="carousel">
<li class="carousel-item" carouselindex="1">
<a href="/someurl"><img src="/someimg" alt="" /></a>
</li>
<li class="carousel-item" carouselindex="2">
<a class="active" href="/someurl"><img src="/someimg" alt="" />
</a></li>
</ul>
So, in this example, I'd like to return a variable that = 2.

View 3 Replies View Related

JQuery :: Copy Element Attribute Values To New Element?

Sep 7, 2010

I would like to change all img tags with a certain class on the page as follows [code]...

I do not know how to "copy" the value of the img tag src attribute to the background url attribute of the div.

View 2 Replies View Related

JQuery :: Get All Child Control ID Or Attribute Or Tag Name In Parent Div

Mar 25, 2011

I have a Div control d1and in this div I have furter div and span control.I want to get a list of all element in an array.

<div id="d1">
<div>
<div id="h1">
<div id="h2">

[Code].....

View 2 Replies View Related

JQuery :: Specifying Variable In Parent To Match Variable In Ajax File

Oct 21, 2011

Ok, so I've built a member search using ajax to change the results each time a filter is changed. It works great, except one minor issue that I'm struggling with...I just can't specify dynamically in the parent file that linkclass$id opens linkclasscontent$id as I don't know of any way to pass that $id variable back over to the parent.

View 3 Replies View Related

JQuery :: Target Change Css Attribute Of P Tag When Hovering Over Parent Div

Jul 7, 2009

I have the following code

[Code]...

I have the .box class applied to a div basically I what to hover over the div change the background color of the div and at the same time change the text color of any text wrapped in p tags. I am getting close but with this code every instance of the p tag gets swapped out I need to know how to target only p tags in the div that I am mouseing over

View 1 Replies View Related

Code To Get A Parent Spans Id Attribute

Jul 23, 2005

I am trying to pass a value of a <span> tag's id attribute to a
function. The following code is a stripped down version of what im
trying to do:

<span id="6">Name: <input name="name" type="text"><span
onClick="dosomething(???);" style="cursor:hand;">Do It!</span></span>

Where there is a <span> tag with an event handler, onClick, i want to
replace the ??? with something that will get the value of the parent
span tag, which in the above case would be &#396;'. i dont want to simply
enter 'dosomething(6)' as the innerHTML of the <span> tag will swap
between other <span> tags with different attribute values. if the code
could also be relative if possible too.

View 2 Replies View Related

JQuery :: Child - Get The Href Attribute In A Variable?

Aug 3, 2010

How can I get the href attribute in a variable?

View 1 Replies View Related

JQuery :: Passing A Variable Through An Attribute Filter?

Nov 3, 2009

This is my very first post! so please be kind Ok, i am very novice to jQuery. But what i am trying to do is use the jQuery attribute selector to select an input with a specific name. I can select an input of name type fine by doing the folowing:

[Code]...

View 2 Replies View Related

JQuery :: Passing A Variable In [attribute] Selector?

Dec 17, 2010

I am new to jQuery. How can I select all the elements with a given number and which has 0 has value and set to a specified value.

[Code]...

View 3 Replies View Related

JQuery :: Attribute Selector As Variable Not Working?

Dec 15, 2009

Here's what I hope to be a quick question that I should be able to figure out myself... but, unfortunately, I can't...I'm trying to pass a variable into the attribute selector. When I substitute the "+myHref+" for "http", I get a match. When I log the myHref var, I get a match. What's wrong with my syntax? Why isn't the myLink finding a match?

[Code]...

View 3 Replies View Related

JQuery :: Using Attribute Selector With .load() Or Variable?

Oct 5, 2010

I try to load specific text from a page into a string. When I'm on the specific page I can do this as follows: var wantedText = $("td > span[style='color: #00AA00; font-weight: bold;']").text();But I want to get this text from another webpage using AJAX, I tried using .load() as follows:

$('#somediv').load(Url+" td > span"); //this loads 3 spans into #somediv (including the one I need)
$('#somediv').load(Url+" td > span[style='color: #00AA00; font-weight: bold;']"); //this does nothing
I also tried loading the entire page into a string using .ajax() like this:

[Code]....

View 3 Replies View Related

JQuery :: Get Attribute Of Element Selected By Name?

Jul 23, 2009

I am just working on a project where i have to replace the href-attributes of all links by another string. The problem is, that i need the old href-attribute to generate the new one, and i have no idea how to get it

i tried it with something like this, but it doesnt work [code]...

I know there is some way to do it but i forgot it and i looked up the whole internet for it and didnt find it

View 1 Replies View Related

JQuery :: Get An Attribute From A Selected Element?

Jun 3, 2011

What I’m trying to accomplish is set an attribute called opacityin any element with a specified value that can be used to toggle whenever the user hovers over the element. The code below works perfectly but one other thing I would like to be able to do is retrieve the attribute opacity after the document loads and fade the element to that value instead of hard coding the ".66". This is probably fairly easy I've just never ran into a situation where I needed to do this.[code]...

View 2 Replies View Related

JQuery :: How To Add Attribute Like Mouseover To Element

Feb 16, 2011

I quite like the fact that you may add through JQuery an attribute like alt or title to an element. And I can see that you may also add mouseover using:
$('#aa').mouseover(function(){//does something in here});
However, I want to be able to pass some very specific values too and that's where I'm stuck for an answer. Suppose I want to attach the following:
mouseover="hm(this,'la1',5)"attribute to an <a> tag.
How do I do this by using exactly those values inside the "hm(this,'la1',5)" ?

View 2 Replies View Related

JQuery :: Select An Element With A Particular Attribute?

Jun 24, 2010

I have a standard menu structured with an unordered list. Some of the items in the menu have sub items, but are not themselves links. Here's an example:

<ul id="mainMenu">
<li><a href="">home</a></li>
<li><a>services</a>
<ul>

[Code].....

How do I select a tag that does (or does not) have a particular attribute? In my case, I want to be able to select all <a> tags in #mainMenu that do not have the href attribute.

View 7 Replies View Related

JQuery :: Change An Attribute Of An Element?

Jun 24, 2010

I am trying to change an attribute of an element but can't figure out what the selector is to select it.

the page code is like this

<div class="slideshow" id="slideshow"><span class="image-wrapper current" style="opacity: 1;"><a title="" href="#2" rel="history" class="advance-link"> <img alt="" src="images/samples/1.jpg"></a></span></div>

I want to add a top css attribute to the img tag.

I tried many things such as

$('.advance-link:first')
$('.advance-link:firstChild')

but none seem to be working. The img gets generated by another script so I can't add an id or class to it. I figured an expert at selectors would be able to explain how to select it.

View 5 Replies View Related

JQuery :: Getting Value Attribute Of Input Element ?

Oct 2, 2010

I have a table with several columns containing input elements populated from a database, e.g.,

On every row, I need to perform a calculation using the value of several input fields. So I tried to access the value of the first input field like so (which had worked in another function):

But for some reason it's returning a 0, and the line below also doesn't work:

But this returns the correct class, so I know it's finding the element:

And if I assign the input element an id, say "count," this works:

Obviously I don't want to fuss with individual id's to get the values. How to understand why the first two examples don't work, and how to fix them?

View 3 Replies View Related

JQuery :: How To Find Image Element By Attribute

Dec 24, 2011

I'm having trouble finding the image element by attribute "MyAttr" whose value is supplied: when the "onclick" function is called:
<div class="MyImages">
<div class="imageClass">
<img ... myAttr="abc"/>
</div><div>
<img ... onclick="findTheImageObjectByMyAttr("abc");" />
</div><div class="imageClass">
<img ... myAttr="def" />
</div><div>
<img ... onclick="findTheImageObjectByMyAttr("def");" />
</div></div>

View 2 Replies View Related

JQuery :: Get The Id Or Other Attribute Value Of Element That Caused Event?

May 6, 2010

I have a set of elements with the same function attached, how do I get the ID or other attribute value of the element that caused the function to be called?

View 2 Replies View Related

JQuery :: Removing A Character From The SRC Attribute Of An IMG Element?

Oct 28, 2010

I tried the code bellow, but it didn't work:

<script type="text/javascript">
$("img").this.src = this.src.replace("1","");
</script>
My html code is this:
<img src="images/1backg.png" />

View 2 Replies View Related

IE: Unable To Modify The Parent Container Element Before The Child Element Is Closed

Mar 16, 2010

The bit of code in bold in the code below is giving me this error in IE: Error: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; Tablet PC 2.0; InfoPath.2; OfficeLiveConnector.1.4; .NET CLR 3.0.30729; OfficeLivePatch.1.3; MSN OptimizedIE8;ENGB)Timestamp: Tue, 16 Mar 2010 15:07:11 UTC Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)

[Code]....

View 1 Replies View Related

JQuery :: Showing A Random List Element Depending On It's Attribute's Value?

Mar 28, 2011

I have a page which contains an <ul> list with 5 items. Each of those items has a data-weight attribute which corresponds to its importance in the list. I have to make only one random list item appear and use the weight to make sure that the most important one shows up more often than the least important item.

View 1 Replies View Related

Changing An Element's Element Attribute

Jul 19, 2006

<div id="div1" onmouseover="this.href.innerHTML='different click name'">
<a href="somewhere">click</a>
</div>

I know this.href doesnt work - Is there a way to access the <a> element without assigning an id to it ?

View 3 Replies View Related







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