jquery-selectors

Select every nth item in jQuery?

jQuery has the handy :even and :odd selectors for selecting the even- or odd-indexed items in a set, which I'm using to clear every other item in a series of floated boxes, as follows: <div class='2up'> <div> ... </div> <div> ... </div> ... <div> ... </div> </div> and // Clear every 2nd block for 2-up blocks $('.2up>div:e...

I want a function to be fired whenever one option of a radio element is checked. The radio elements are dynamically created by using Jquery

I want to place a function on input radio elements. These input radio elements are created dynamically by using Jquery.One dynamically-created(by user's click) input element looks as follows: <div class="below"> <input type="radio" value="information" name="option0"/> information <input type="radio" value="communication" name="option0"/...

jQuery: Problem with :odd selector

hi all, i'm having a table with several rows - i assigned a hover function to each row. what i wanna do is find out in my hover funtion if the selected TR is odd or even. i used this code: alert(tr.is(":odd")); unfortunately it doesn't work although it should(?) i'm always getting "false". i tried getting the rowIndex directly from...

How to know how many of a particular kind of element exist in the current web page in Jquery?

There are many <label name="delQ" style="cursor:pointer">Remove</label> elements in a web page; the elements are dynamically created. How to determine how many "delQ" exist in the current web page? $('[name="delQ"]').live('click', function() { //Get the number of name="delQ" in the current web page. }); How to do it in Jquery? ...

Changing jquery cluetip dynamically

Hello, I am trying to change the cluetip content dynamically by changing the title attribute dynamically as I am using the cluetip plugins splittitle method to generate the cluetip on a table row. I am using the jquery attr(key,value) method to change the title value but the title remains the same as the one which is loaded the first ti...

jquery selecting a particular class from an element

I'm trying to group related elements using class name. They, in turn, are all related as they are all using the same prefix for the class name. Example: <ul> <li class="category-fruit"></li> <li class="category-grain"></li> <li class="category-meat"></li> <li class="category-fruit"></li> <li class="category-meat"></li> </ul> ...

jQuery syntax selectors, are these the EXACT same thing?

There are some preferences I have observed for the selection syntax such as: $('#mydiv > a.selectMe').hide(); $('#mydiv').children('a.selectMe').hide(); To me, it seems a bit confusing as the documentation for jQuery is a bit ambiguous here: " parent > child Returns: Array Matches all child elements specified by "child" of element...

li:lt(4) is not getting all list items less than the count of 4?

This is my HTML: <ol id="front-page"> <li> <img src="images/defaultImage.gif" alt="Default Image" /> <a href="#" title="Title Entry">Title Entry</a> </li> <li> <img src="images/defaultImage.gif" alt="Default Image" /> <a href="#" title="Title Entry">Title Entry</a> </li> <li> <img src="images/defaultImage.gif" alt...

jquery select parent problem

Sample html markup below <div class="container answer_comments"> <p class="comment_text">Hey that's not cool.</p> <p class="comment_attribs">By Anonymous User on 01 Dec</p> <p class="comment_text">Is that really why?</p> <p class="comment_attribs">By person on 27 Nov</p> <p class="close_comments" onclick="close_comments()">Close</p> </d...

jquery select siblings 'until'

I have a DOM in the form of <input class="parent"></div> <input class="child"></div> <input class="child"></div> <input class="parent"></div> <input class="child"></div> ... which I know is not Right and the right way to do this would be to reform the HTML, but lets say that is not possible. How can I get jquery to select all childr...

Showing a div element dependent on if it has content

Hello, With jQuery I am trying to determine whether or not <div> has content in it or, if it does then I want do nothing, but if doesn't then I want to add display:none to it or .hide(). Below is what I have come up with, if ($('#left-content:contains("")').length <= 0) { $("#left-content").css({'display':'none'}); } ...

How can I simplify this jquery?

I have the following jquery which I want to simplify. I am just repeating the same things. Could anyone give me suggestions please. Thanks in advance. $("a[rel='imagebox-all']").colorbox({slideshow:true}); $("a[rel='imagebox-new']").colorbox({slideshow:true}); $("a[rel='imagebox-even']").colorbox({slideshow:true}); $("a[rel='imagebox...

jquery, how to animate element after being sure that it's not being animated at the same time

$("sth").not(':animated').animate(); hey is this the best way to animate element after being sure that it's not being animated at the same moment ? thanks ...

How can we use $(this) and option selected

$('#selectList :selected').text() is known syntax i have to fetch the value for the same from $(this) instead of $('#selected') something like this $(this :selected').text() ? ...

How do the performance characteristics of jQuery selectors differ from those of CSS selectors?

I came across Google's Page Speed add-on for Firebug yesterday. The page about using efficient CSS selectors said to not use overqualified selectors, i.e. use #foo instead of div#foo. I thought the latter would be faster but Google's saying otherwise, and who am I to go against that? So that got me wondering if the same applied to jQuer...

jquery, performance-wise what is faster getElementById or jquery selector?

Hello, What is better from performance wise document.getElementById('elementId') or $('#elementId') ? How can I calculate the speed by myself? Thank you and Kind Regards. ...

Jquery Fade Effect On Form Input Focus

this question is similar to my previous hover question (http://stackoverflow.com/questions/1851141/converting-css-hover-to-jquery-hover) but the answer will be different because it involves a click function and two bgs. I am building a contact page, and when the user clicks on one of the input fields, I want the background of the input ...

jQuery set value only if empty

I am utilizing a modal for setting a default value for a series of text box fields. However, I only want to set the field to the default value if no value already exists. Is there a way to do that with a jQuery selector? Current Code var fooVal = $('#cboxLoadedContent').find('#SetFoo').val(); var barVal = $('#cboxLoadedContent').find('...

Using jQuery, how do I find all instances of a class that appear between another class

For example: <table> <tr class="highlight" id="click"> <td>Rusty</td> </tr> <tr class="indent"> <td>Dean</td> </tr> <tr class="indent"> <td>Hank</td> </tr> <tr class="highlight"> <td>Myra</td> </tr> </table> Say when I click on the hr with the id click how would I find all instances of class indent unti...

Selector regression after upgrade to jQuery 1.3.2

I've recently upgraded an application from jQuery 1.2 to 1.3.2 - and we've found a rather strange regression. For some html approximately like this (simplified a bit) <div id="steps"> <div class="step"> <span>step #1</span> <div class="removeStep"> X </div> </div> <div class="step"> <span>step #2</span> <div class...