selector

Complex CSS selector for parent of active child

Is there a way to select a parent element based on the class of a child element in the class? The example that is relevant to me relating to HTML output by a nice menu plugin for http://drupal.org. The output renders like this: <ul class="menu"> <li> <a class="active">Active Page</a> </li> <li> ...

jQuery - How to Select Multiple Descendants?

I have this form: <form name="customize"> Only show results within <select name="distance" id="slct_distance"> <option>25</option><option>50</option> <option>100</option><option value="10000" selected="selected">Any</option> </select> miles of zip code <input type="text" class="text" name="zi...

Style ancestor element of form input:focus (jQuery)

I have a form with a DIV, 3 INPUTS, each INPUT sits within a LABEL element. I would like to change the background image of the DIV element when focusing on each INPUT. I can't move back up the DOM to fix this with CSS, so could someone suggest a few lines of jQuery please? Thanks ...

$(this) selector and children?

I'd like to use a selector to select the child img of the div I'm clicking on this example: <div id="..."><img src="..."></div> To get the div, I've got this selector: $(this) How do I get the img with a selector? ...

jQuery select descendants, including the parent

Consider the following HTML <div class="foo" id="obj"> I should be changed red <div class="bar" style="color:black;"> I should not be changed red. <div class="foo">I should be changed red.</div> </div> </div> Given a DOM element 'obj' and an expression, how do I go about selecting any children and possibly 'obj'? ...

What could possibly cause JQuery's selector to break?

I am trying to get an element using JQuery's selector, but it does not find it even though the element actually exists. Moreover, I can actually find the element using getElementById. For example: $('#outputDiv') gives me a null value. But document.getElementById("outputDiv") returns me the Div I was trying to access. Any idea? ...

How can I speed up jquery :selected selector?

I have a dropdown in a web page with 3830 elements in it. I know, excessive but whatever. In jquery I get the selected option value using the statement: $( "#institutionCombo :selected" ).val(); There is a noticeable pause before the selection is found. Once I get that value I insert it into a textbox on the page, so I know how fast. ...

Help me optimize this selector? $('#data div.item:has(div.video_guid:empty)')

It's currently not so slow as to make the site unusable, but in mobile safari on the iphone there is a noticeable lag. Is there a simpler way to do this? "Find div.items that have an empty div.video_guid" ...

jQuery element selector issue

My problem is a little bit complex. I have the following code: $(document).ready(function() { var hash = window.location.hash.substr(1); var href = $('#nav li a').each(function(){ var href = $(this).attr('href'); if(hash==href.substr(0,href.length-5)){ var toLoad = hash+'.html #content'; $('#content').loa...

What is fastest children() or find() in jQuery?

To select a child node in jQuery one can use children() but also find(). For example: $(this).children('.foo'); gives the same result as: $(this).find('.foo'); Now, which option is fastest or preferred and why? ...

Is there a jQuery selector/method to find a specific parent element n levels up?

Consider the following HTML. If I have a JSON reference to the <button> element, how can I get a reference to the outer <tr> element in both cases <table id="my-table"> <tr> <td> <button>Foo</button> </td> <td> <div> <button>Bar</button> </div> </td> </tr> </table> <script type="text/js"> $('#table button').clic...

JQuery event selector

Say i have 10 small images that i want to use as tooltips. Im assinging them all the same class, '.helper' Im selecting helper, then calling mouseenter(function() { $(".helper").stop(false,true).fadeIn(); }) I then want a div to popup, containing some text. This works fine if there's only one tooltip on the page, but as soon as ther...

XPath to select multiple tags

given this simplified data format: <a> <b> <c>C1</c> <d>D1</d> <e>E1</e> <f>don't select this one</f> </b> <b> <c>C2</c> <d>D2</d> <e>E1</e> <g>don't select me</g> </b> <c>not this one</c> <d>nor this one</d> <e>definitely not this one</e> </a> ...

JQuery selector value escaping

Hey all, I have a dropdown list that contains a series of options: <select id=SomeDropdown> <option value="a'b]&lt;p>">a'b]&lt;p></option> <option value="easy">easy</option> <select> Notice that the option value/text contains some nasty stuff: single quotes closing square bracket escaped html I need to remove the a'b]<p> opt...

jQuery: selecting checked checkbox

Suppose I have the following HTML: <form id="myform"> <input type='checkbox' name='foo[]'/> Check 1<br/> <input type='checkbox' name='foo[]' checked='true'/> Check 2<br/> <input type='checkbox' name='foo[]'/> Check 3<br/> </form> Now, how do I select the checked input fields with name 'foo[]'? This is my try, but it doesn't work: $('...

Android : Customizing tabs on state : How do I make a selector a drawable

I know how to put the icon on each tab, that is no problem. I also ran across this : Stack Overflow thread on pretty much same thing I followed one of the links from that question, and found this Pretty much, it said use a selector defined in the xml, sure, did that. But there is no id associated w/ it so I am not sure how to get the s...

jQuery selector where text = some value

I have an object (in this case a rating object from js-kit) that I want to make invisible if the rating value is 'unrated'. I'm having trouble with geting the right jquery selector to do this. It seems like this should work... $(".js-rating-labelText:contains('unrated')").css("visibility", "hidden"); ...but does not. .js-rating-label...

Need JQuery to select a table only if its 1st row has more than 1 column

I need to select and act on a table element with JQuery, but only when it contains at least one row with more than one column. The following selector works, but only gets me part way: $('#my_table_is:has(tbody tr)').doSomething(); Variations I have tried with no success are: $('#my_table_id:has(tbody > tr > td:eq(1))').doSomething();...

sIFR 3 - Selector

I'm using sIFR 3 (beta revision 436). I have a simple question, but I can't figure out the solution. I want to select an <a>-tag directly by it's class, not by its parent like I'm doing now: sIFR.replace(din, { selector: '.mainmenu' ,css: [ '.sIFR-root { font-size:13px; text-transform:uppercase; cursor:pointer; text-align:ce...

load html page with jquery and select element from it

Hello, I am having a problem with selecting an element from a previously loaded html page if I use this code, the one before last is designated too be the last in the dom-tree instead of the one that I just inserted $("div.wrapper:last").after('<div class="wrapper"></div>'); $('.wrapper:last').load('tbnote.html .pane'); $(".pa...