jquery-selectors

Jquery > Selector

In this example (which is working) on click of a button the section is toggled visible/invisible. Great but what is the code in line 2 actually doing?? I have found a reference to the :eq(0) part here on jQuery.com but the '>' I have no clue. Under firebug it doesn't seem to matter if the '>' is there or not. $("#btnHideShow").click(fu...

jQuery select just the first one

My javascript $(".controls").click(function(event) { var div = $(event.target).parents(".controls"); var a = $(div).find("tr .select"); return false; }); And html <div id="grid1" class="controls"> <a href="/projekt/create">Add</a> <a href="/projekt/edit...

Two functions off one event

I currently have two input fields which toggle the value "value" to either true or false. What I would like to happen is that when the user hits the submit button, I can run an if/then statement for each input field and pass a different variable for each field, then combine those two variable into one variable. For example. if ($('inp...

How can I count the number of children of a DOM element?

I would like to determine the number of images inside a certain div. I am fairly sure I have the code to select the elements I would like to count: var imageCount = $("#work img").size(); And the div itself couldn't be simpler: <div id="work" class="shown"> <img src="graphics/gallery/001.jpg" /> <img src="graphics/gallery/002.jpg"...

How to dynamically add an active state with jQuery to a gallery thumbnail

I'm using galleriffic to handle my image gallery and I'm having a problem with the thumbnail active states. Galleriffic doesn't have support for active states on the images - only the list items. Right now the gallery will assign a "selected" class to the current LI containing the thumbnail and I've been trying to use jQuery to target t...

jQuery - Select EVERY UL of last LI in list

Hello, I'm trying to format my list of items, where the html goes like this: <ul class='product_list'> <li>Item 1 <ul> <li>Item 1.1</li> <li>Item 1.2 <ul> <li>Item 1.2.1</li> <li>Item 1.2.2 <ul> <li>Item 1.2.2.1</li> ...

Dynamically create Fancybox and stick video into it

Hi. I need to replace all the HTML5 video tags on the page with their poster image that has a click event attached; the click event launches a Fancybox containing that video tag. Anyone know how to do this with jQuery? Thank you. ...

jQuery having trouble selecting things in different cases

Note: If you're 'just' a jQuery developer some things in this post may look a tad complex (Base62 encoding etc.) - it's really not. Although the more technical details are relevant to the question, the core is that jQuery won't select stuff with capitals. Thanks! Hi folks! So I have a list generated by Ajax. When you click the list's t...

JQuery selector multi-class objects

Hey all, I've been trying to get a series of objects to appear that have multiple classes associated with them <div class="Foo Bar"> Content </div> <script> alert($('.Foo').length); </script> The selector above is returning 0. This is unfortunately one of those questions that is completely impossible to ask to google (at leas...

How to set first option's value of Select Box using jQuery?

I have a select list: <select id='myList'> <option value="">zero</option> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> How can i set the value of option value to = 0 using jQuery? I tried $("#myList > option").attr("value", "0"); But thi...

Caching of jQuery references

Is it always best practice to use: var $this = $(this); Or is $(this) cached and therefore the above line is just for saving two characters? ...

jQuery find elements of class name within same container

I have a UserControl in MVC which may be repeated many times on the page. Say I had something like the following: <div> <a href="#" class="enableTextBox">edit</a>" <input type="text" class="comments" readonly="readonly" /> </div> <div> <a href="#" class="enableTextBox">edit</a>" <input type="text" class="comments" rea...

jquery selector not working in IE

Hey there, these two selectors is not working in Internet Explorer 8 (they work okay in Firefox, Safari and Chrome). $(this.children).stop().animate({ color: "#4B2B26" }, 300); $(this).find('a').stop().animate({ color: "#4B2B26" }, 300); Help is appreciated, thanks! edit; I think it's a problem with jquery.js.. Each time i hover a o...

JQuery: How determine child ordinal position? Need: $("#parent").ordinalChild('#some-child') => 3 (say)

Because Jquery UI tab doesn't support passing id selector to remove() tab method, and no method exists to map id to index, I have to painfully "jump hoops" to determine the index of the tab I wish to remove. I just searched the documentation for JQuery and wasn't able to find a utility method to return an integer of the ordinal positi...

jQuery - select one of the two classes

Hi, I have a table row elements: ... <tr index="1000" class="class1 classHighlightRed"> ... ... <tr index="1000" class="class1 classHighlightYellow"> ... I would like to check the value of the second class against some constants. E.g. If (2nd class == "classHighlightRed") Then { doSomeWork; } At the moment...

JQuery Selector: Select element based on text

I want to select an element based on their innertext in JQuery. Below is my Html <html> <body> <a href="fddf">4</a> <a href="fddf">4</a> <a href="fddf">4</a> </body> </html> I want to select all the <a> tags which has text of "4". Any idea how do I do it? ...

How do I select an image based on its path/url?

I'm tying to select images based on their URLs, but for some reason it's not playing ball: Ultimately I'm after something like: var imgs = $("img[@src='images/object.png']:not(:hidden)"); But even with something simple like: $("img[@src='images/object.png']"); This error is thrown: "TypeError: Object doesn't support this property ...

How do I select a closest ancestor plus the ancestor's next?

I'm using jQuery to manipulate table rows that are paired within a table. I'm trying to select rows based on found items from my previous jQuery where if the row contains a visible image, I need that row and it's next sibling. I can get the row using: $("img[src*='file.png']:not(:hidden)").closest("tr"); Because I'm also after the s...

Applying a colspan attribute on selectors recursively using jQuery

This is my HTML page.. If you copy paste this complete HTML in a browser you would see that the second section has Elements and Duration while the third section has Elements and targeted resources, In this case i want to dynamically change the 2nd and 3rd row to expand like the first one. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran...

jQuery hover w sticky click/selection problems in IE

Ive made a 'hover with sticky click' jquery script for my web portfolio which works in Chrome, Opera, Firefox, and Safari - but I'm still having some problems with IE. I have 8 thumbnails that fade between 0.3 and 1 opacity on hover. When clicked it uses the index of the thumbnail to show the corresponding full size image. It also is li...