jquery-selectors

Select the first element of a class 'x' after a link with jQuery

Hello, I've got some code like this: <p>Lorem ipsum<a href=# class="a">link</a><span class="b">Text</span>More lorem ipsum<a href=# class="a">link</a><span class="b">Text 2</span> And I'd like to let users click the link and be able to do something with the span (make it flash, hide it, whatever). I'm using jQuery, and this is what...

How can I prevent jquery from selecting a parent when I click on one of the children in that parent?

Hi all, ok quick scenario: html: <span class="answer">blah<input type="radio" value="1"></span> jquery: $("span.answer").click( function() { check = $("input", this); check.attr('checked', check.attr('checked') === true ? false : true); ); Ok so this will check/uncheck the child radio input inside the selected span when I click ins...

jQuery - remove class from element when :hover

I have a nested list. The nav-ul is hidden unless you are on that page, in which case jQ adds the class selected. I have written a jQuery script to handle the highlighting of the current location but what I am having trouble with is hiding the nav-ul when you hover over a top level li. Item 1 | Item 2 | Item 3 | Item 1.1 | Item 1.2 | I...

jquery find div or select by name returning 0 results

I'm trying to select a <div> inside of a <p> by name, but it's returning 0 results. The same type of selection works fine for <input> and <span>, but not for <select> and <div>. The code below demonstrates what I mean: <html> <head> <script type="text/javascript" src="jquery-1.4.1.min.js"></script> </head> <body> <p id="foo"> ...

Tricky little jquery selector one : loop over all inputs, and exclude only non-checked radio buttons

Here's the deal : in order to build a correct series of parameters, i'm trying to loop over all inputs included in an ajax built form; Code down here isn't finished, yet I guess you will understand it : $("#formulaireUploadFichier").live('submit',function(e){ var fm = $(this); var fld = []; $('input',fm).not('[type=submit]')...

jquery hasClass matching element

In jquery can I combine "closest" or Parents() with "hasClass", so it will give me a closest element with given class, if it exists on a page? var matchingDiv = $(this).closest('div').hasClass('SomeClass') if ( matchingDiv != null ) { //we found matching element now manipulate it } I will always have either one matching div eleme...

Jquery binding event.

<img id="sun" href="logo.jpg"/> How do I use JQuery to bind it so that when "sun" gets clicked, something happens? I just want bind onclick to sun. ...

Close parent div

Hi, I have a set of div's with some child elements.Inside parent div I have a hyperlink. If I click the hyperlink, then i want to close the parent div of the currently clicked link, not other div's. Ex: <div class="1"><a href="#" class="closeThis">close</a></div> <div class="2"><a href="#" class="closeThis">close</a></div> <div class...

jQuery - find a value relative to a clicked element

I am trying to get the text value of a table cell relative to a clicked link. Click the link in any of the cells of class 'three" and get the text of that particular row's cell named class 'one'. <tr> <td class='one'><a href="#">Text to get</a></td> <td class='two'>meh</td> <td class='three'><a href="#">Click this to get the text in th...

jQuery - get all links with inner html "value"

<div> <a> Text1 <img alt="" stc="" /> </a> <a> Text2 </a> </div> I want to select all a elements that have text=text2. I looking for something like that: $('a[text=Text2]') Edit: Why this is not working? (from some reasons it's need to be in this format). $('div').find('a').find(':conta...

How to pass multiple selected (through checkboxes) row ids to a php script in jQuery?

I'm generating an html file which looks like: <tr id="ID001" property1="PROPERTY001"><td><input type="checkbox" name="row_checkbox_ID001"></td><td>...</td><td>...</td></tr> <tr id="ID002" property1="PROPERTY002"><td><input type="checkbox" name="row_checkbox_ID002"></td><td>...</td><td>...</td></tr> When the user select...

How do I get the name or id of the element ?? Jquery

How do I get the name or id of the element to jquery ...

Check if value is in select list with JQuery

Hi all, How can I, using JQuery, check if a value belongs to dropdown list or not? Thanks in advance. ...

Selecting all the divs with png background-image

How can i select in jQuery all the divs that have background-image: Url('somepath/somename.png'); in their style? Thanks. ...

jquery - get all rows except the first and last

i want to dynamically add a class to all rows of a table except the first and last row. how would i do this without assigning a css class to the rows to identify them. I am getting all but the first row currently with $("#id").find("tr:gt(0)") i need to combine this with not("tr:last") somehow maybe? ...

jQuery select all except first

In jQuery how do I use a selector to access all but the first of an element? So in the following code only the second and third element would be accessed. I know I can access them manually but there could be any number of elements so thats not possible. Thanks. <div class='test'></div> <div class='test'></div> <div class='test'></div> ...

How can I apply a lightbox (prettyphoto) to all images in the content div?

Hi, I have a lightbox script installed and now I want to apply the script on every image within the content div. How can I achieve this? My current JS code: <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $("a[rel^='prettyPhoto']").prettyPhoto(); }); </script> The css/div I want it applie...

Which is more efficient: .parent().parent().parent() ~or~ parents(".foo") ~or~ closest(".foo")

I have an A tag which triggers the animation of it's great-great-great-grandparent. All of the following will work, but which is most efficient, and why? $(this).parent().parent().parent().parent().parent().animate(...); $(this).parents(".foo").animate(...); $(this).closest(".foo").animate(...); I suspect that the first might be, a...

Most appropriate way to select first occurrence of a child element in jQuery

I have a list like so: <ul id="topElement"> <li></li> <li> <ul> <li> <ul> <li> </li> </ul> </li> </ul> <li> Using jQuery, what is the best aka most efficient way to reference the first occurrence of a ul from #topElement. That is to say, I do not want this... $("#topElem...

Using jQuery to select items that have style "visibility:visible" or "visibility:hidden" NOT "display: none"

How do you select only visible elements using jQuery? jQuery selectors :visible and :hidden only respects display:none as really hidden? NOT visibility:hidden or visibility:visible. I understand they are not technically hidden because they still take their space. I just want to know their state so I can check checkboxes that are visibl...