selectors

Getting a jQuery selector for an element

In psuedo code, this is what I want. var selector = $(this).cssSelectorAsString(); // Made up method... // selector is now something like: "html>body>ul>li>img[3]" var element = $(selector); The reason is that I need to pass this off to an external environment, where a string is my only way to exchange data. This external environment...

travesersing the dom with inexact parameters

Hi, I want to grab the image src on a product page in a e commerce website. I'm writing this as a bookmarklet, so I'd like the code to work universally as possible. I've noticed that there are only two reoccurring factors in the product image tag among top e-commerce websites (amazon, bestbuy ect.): border=0 and 180<width&height<400. S...

how do i do a find to get any div that has an id that starts with a certain string

i have some dynamic code that will make a list of divs. i want to get back a list of items to loop through that have an id with the same start of the string. For example, i might have <div id="table1" . . . <div id="table2" . . . <div id="table3" . . . how, using jquery, can i get a list of all divs that have an id that starts with ...

JQuery : selector chain with attribute filter : result does not persist?

I am pulling my hair out!! grrr... This seems to work: //get all the foo and bar links that point to a named anchor: $("a.foo,a.bar").filter("[href^=#]").click ( function() { doSomething( $(this).attr("href").substr(1) ); return false; } ); When I log the output of '$(this).attr("href").substr(1)' to the c...

Android ListView - Multiple <Selector> Tags

Is it possible to have multiple selector tags on a single listview...ie: change the background color of each item of the listview (alternating between two drawables), but still have the selector of the list view active for focus and click events? Also, is it possible to ensure that the margin stays constant when using selector tags? Fo...

iphone dev - problem with @selector

Hi guys in my app I am trying to run some code that currently exists in my applicationWillTerminate in appDelegate. I have c/p'd the same code into the method that is currently running (verified by NSLog), but the code just doesnt seem to execute the same way. The following code is from my applicationWillTerminate, which saves data, re...

Can I put an ObjectiveC @selector in a NSDictionary?

[actionMap setObject:@selector(actionNavPop) forKey:@"navPop"]; This doesn't work. NSDictionary can only hold objects, and a SEL type is not an object. For number types you can do [NSNumber numberWithInt:123] but is there any sort of similar object wrapper for selectors? ...

Descendant selectors or specific classes?

Suppose I have this markup: <div id="#titles"> <p>Intro text <span>text text</span> text text</p> <ul> <li>text text text</li> <li>text <span>other text</span> text text more text</li> <li>text text text</li> </ul> </div> and I want to style the span which is inside the li is it better to use the descendant selector #titles li span or...

How can I make the nested links active again?

I am making a nested ul slide down when it's parent is clicked on for a clients navigation, so the parent link is deactivated with return false. But the return false is deactivating the child links too, how can I avoid this? $("li.page_item a:first-child").click(function() { //select it's direct sub ul var subnav = $(this).next...

Receive index with jquery

while selecting the desired element is simple in jquery i haven't found one way to receive an elements index here's an example of what i want. $('#minia .holder a').click(function () { }) this function is used obviously to catch any clicks on one of thoose elements to catch that specific element I use $(this) now my question is how w...

How can I associate a live event with an index selector using jQuery?

I have the following HTML: <ul id="tabs"> <li><a href="...">One</a></li> <li><a href="...">Two</a></li> <li><a href="...">Three</a></li> </ul> I want to perform a unique action when someone clicks on each of the links. I tried the following and it did not work $("#tabs li").eq(1).live('click',function(){alert('ONE....');...

MooTools: Get child nodes

I have the ID of an element. I want to retrieve all child elements and all text nodes. Is there a way to do this in MooTools? For example, say I have this markup: <div id="foobar"> test <img /> </div> How can I use $('foobar') to select both text node "test" and element "img", like they're siblings? ...

Problem with Java selector/SocketChannel

I'm having a problem with a multiplayer game. Right now, I'm just trying to get the server to send the current level to the client. The server is definitely sending the data, but it never gets to the client application. Client code: public void run() { while(true) { try { sel.select(); Set r...

How do i find a specific form using jquery and a link i clicked

I have a link and would like to show/hide ONE form. The first line does it but it does it to ALL forms inside of the one in its own comment div. How do i select the form. the other 3 were guesses and dont work (they seem to do nothing at all). I'm thinking going up to the comment, then down to the form and use toggle on it (as the first ...

jquery nth child that is currently visible

I can style every 4th 'item' div like so jQuery(".item:nth-child(4n)").addClass("fourth-item"); and that works fine, but then I hide some items, show some others and want to re-do this styling, but only styling every 4th item that is visible. So I have a function that will remove this styling and reapply it, but I need to specify in...

Finding text node

Is there a clever jQuery selector for selecting a text node like this: <div><input type="text">one <span>two</span> three</div> I would like to get three from the markup above and wrap it in a strong tag like this: <div><input type="text">one <span>two</span> <strong>three</strong></div> ...

jQuery :nth-child selecting just one?

$('.mydiv ul li:nth-child(4)').addClass("nth"); There are atleast 8 li's in there but it only selects 4th but not 8th? ...

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...

What's this jQuery code snippet doing?

allFields = $([]).add(name).add(email).add(password) $([]) ?? ...

Select all checkboxes with jQuery

Hello everyone! I need help with jQuery selectors. Say I have a markup as shown below: <form> <table> <tr> <td><input type="checkbox" id="select_all"/></td> </tr> <tr> <td><input type="checkbox" name="select[]"/></td> </tr> <tr> <td><input type="checkbox" na...