selector

jQuery select ancestor

Is is possible to use jQuery to select an ancestor of an element? Markup: <div id="ancestor-1"> <div> <a href="#" class="click-me">Click me</a> </div> </div> <div id="ancestor-2"> <div> <a href="#" class="click-me">Click me</a> </div> </div> Script: $(".click-me").click(function(){ // var ancestor...

How to restrict affecting range with jQuery?

<table> ... </table> <script type="text/javascript"> $(selecctor).click(...) </script> The above is to be dynamic loaded by ajax. What I want to do is restrict the selector so that it only affects the DOM within the table above it.I( can't assign an idto the table) EDIT To Gumbo's solution: <div id="container"> </div> <table> .. <...

Element or class LIKE selector for JQuery?

For whatever reason I have these classes called .main_sub1, .main_sub2 etc. Never mind why I can't have .main .sub. Is there a way with JQuery, sort of in the way it is possible to do with attributes, to get the classes containing main? ...

how to create an "array of selectors" in objective-c

Hi, i'm using the iphone sdk (3.0) and i'm trying to create an array of selectors to invoke a variety of methods within one class. Obviously, I'm doing something wrong (I think @selector isn't considered a class and so stuffing them into an NSArray isn't working). I tried this, but it's obviously wrong. Is there a simple way to have...

iframes with jQuery

Hey all, I have a script which is purely JS which takes code and inserts it into an iframe: var html = "<p>Some <strong>HTML</strong> to insert</p>" var iframe = document.getElementById('contentsframe'); iframe = (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument.document) ? iframe.contentDocument.document : iframe...

How to verify if a delegate responds to a selector?

Hello, I know I need to write: [delegate respondsToSelector:@selector(myMethod:)] But the compiler is complaining that respondsToSelector is not a method in the protocol, which is correct, However I have seen many sample code use this, how do you do it?. Thank you. -Oscar ...

Fictitious jQuery persist method

Is there a way to have a declaration such as the following persist to all matching elements that are later added to the DOM? $("a.my-class").replaceWith("<span>Replaced</span>"); Something along the lines of... $("a.my-class").persist().replaceWith("<span>Replaced</span>"); (Persist is a fictitious method, that I hope conveys what ...

jQuery OR Selector?

I am wondering if there is a way to have "OR" logic in jQuery selectors. For example, I know an element is either a descendant of an element with class classA or classB, and I want to do something like elem.parents('.classA or .classB'). Does jQuery provide such functionality? ...

css select all descendants (asterisk) of elements with a class

I want to select all descendant elements of the element with class="x" this way: <!DOCTYPE html> <html> <head> <style type="text/css"> .x * { color: red; } </style> </head> <body> a <p> b <p class="x"> c <p> should be red </p> foo </p> </p> </body> </html> which unfortunately does ...

Forwarding method calls to a method with a different signature in Objective-C?

I am trying to implement a JSON-RPC solution, using a server connector object wich obtains a list of available functions from a server somehow like NSDictionary *functions = [server callJSONFunction: @"exposedFunctions" arguments: nil]; wich is a simplified description, since callJSONFunction actually triggers an asynchronous NS...

iPhone: IBAction Causes "Unrecognized Selector Sent to Instance" Error

I'm working on my first real iPhone app, a simple To-Do list application to help me organize stuff, except I'm getting an "unrecognized selector sent to instance 0x". Specifically: 2010-02-20 14:30:09.200 ToDoApp[88562:20b] *** -[NSCFDictionary switchViews:]: unrecognized selector sent to instance 0x3d22de0 2010-02-20 14:30:09.201 ToD...

Problems with .prepend method in jQuery

I have a function that prepends a li tag to a parent div just fine...however, after the prepend, i want to act upon this prepended list item by changing css properties when hovered on but the jQuery selector can't find it (seemingly because the .hover function is searching for list items available to act upon when the page loads..and the...

jQuery :not() issue

jQuery 1.4: $('#menu li:last:not(.ignore)').addClass('last'); HTML: <div id="menu"> <ul> <li>item 1</li> <li>item 2</li> <li class="ignore">item3</li> </ul> </div> .. last class is not applied to item 2. What am I doing wrong here? Thanks ...

jQuery selector for inputs with square brackets in the name attribute

I want to do this: $('input[inputName=someValue]') Except that the name of the input is not 'inputName', it is 'inputName[]'. And this doesn't work: $('input[inputName[]=someValue]') and neither does this: $('input[inputName&#91;&#93;=someValue]') or this $('input["inputName[]"=someValue]') Thanks for any help. EDIT: As som...

jQuery: selector question (images)

I'm having a HTML document which has images to local files like: <img src="file:///C:/... How can I select all images with file:// in the src tag? ...

Android Selector Problem

Hi, i have a listview with a custom item_row.xml. I've defined a selector in this way: <?xml version="1.0" encoding="utf-8"?> <item android:state_pressed="false" android:drawable="@drawable/list_bg" > </item> <item android:state_pressed="true" android:drawable="@drawable/header_bg" > </item> <ite...

How do I execute a function on an event on any element but one with jQuery?

hi, I want to execute a function on an event on any element but one: $(":not('#myelement')").bind('mousedown', function() { console.log('mousedown event'); }); but when I click #myelement, the function is executed anyway, because the selector select all the parents. Moreover, the function is executed for every parent. How can I: ...

jQuery Selector - checked and class begins with...

I need to get the value of the first checkbox which is checked and who's class name begins with 'rqc', eg. rqc205 I have tried this: requestID=$('#requestsTable').find('input[class^='rqc']:checked').val(); but it yields nothing, whereas requestID=$('#requestsTable').find('input:checked').val(); works but does not limit to the class. ...

Jquery: How to get to a particular child of a parent?

Hi, To give a simplified example, I've got the following block repeated on the page lots of times (it's dynamically generated): <div class="box"> <div class="something1"></div> <div class="something2"> <a class="mylink">My link</a> </div> </div> When clicked, I can get to the parent of the link with: $(".mylink").clic...

jQuery .eq(x) returns different element in IE than in FF/Chrome

I am using the .eq() method to select a specific child element of a known element. It appears that the element indices are different in IE and in Chrome/FF, as .eq(2) returns different values depending on browser. (The element I'm looking for shows up as .eq(2) in FF/Chrome, but .eq(3) in IE) For example, alert($(this).parent().childre...