selectors

Select Element By CSS style (all with given style)

Is there a way to select all elements that have a given style using JavaScript? Eg, I want all absolutely positioned elements on a page. I would assume it is easier to find elements by style where the style is explicitly declared: the style is non-inherited (such as positioning) the style is not the default (as would be position:sta...

Slick vs. Sizzle -- Pros and Cons of CSS selector engines

When would I want to use Slick and when would I want to use Sizzle? What are the pros and cons of each as a standalone CSS selector engine? How easily can Slick be used with JQuery? Can Sizzle be used with Mootools? ...

Jquery selector with 2 conditions

I am trying to initiate a function when a click event happens on a link within a list. This is for a menu. Right now, I have this and it works: $(".left-navigation-holder li a:has(~ul)").click(toggleMenu); Basically, the click event initiate toggleMenu if the link clicked has a list (ul) down the tree. Now, I would also have this to ...

Can't set an object in ObjC?

Whenever my method sets an object to onTouchEventReceiver, it gets lost when another method is called by another thread. //In header id onTouchEventReceiver; SEL onTouchSelector; - (void) setOnTouchSelector:(SEL)sel withObject:(id)obj { NSLog(@"setting obj to %@",obj); onTouchSelector = sel; [self setOnTouchEventReceiver:ob...

jQuery selectors, generalising a selector by anchor ID

I've got some code on my site that displays a list of articles on a blog as follows (there will be multiple objects with the same category): <ul class="article category1"> <li> etc <li> </ul> <ul class="article category2"> <li> etc <li> </ul> <ul class="article category3"> <li> etc <li> </ul> I've got some jQuery cod...

Detecting CSS Selector Support of Browser with jQuery

Hi, Normally, i'm using Modernizr for regular feature detection but it can't detect browser selector support (i.e: :nth-of-type() selector). Is there a way to detect selector support of browser with jQuery? ...

Select link based on partial href

Is there a selector in jQuery that will allow me to select all anchor tags that have a href beginning with href="/products/index?page="? My full href is href="/products/index?page=2", but they all have the beginning in common. ...

Test if a selector matches a given element

Hi guys. Is there any way to test if a selector would match a given DOM Element? Preferably, without the use of an external library like Sizzle. This is for a library and I would like to minimize the amount of third party plugins required for the "core" library. If it ends up requiring Sizzle I'll just add that as a plugin to the librar...

jquery reconstructing a selector from a string

I am taking the value of a select element and trying to modify it so that I can have access to the onscreen preview element that the select item represents. Here is the first part of the code... $("#single_area_select").change(function(){ var $element = '#preview_' + $("#single_area_select").val().toLowerCase(); elementC...

Get ID of first LI of UL with jQuery

<ul id="someList"> <li id="listItem1">List 1</li> <li id="listItem2">List 2</li> </ul> Maybe I need to brush up on my selectors, but how would you grab the first ID of ul#someList? Also if I'm prepending LI's to ul#someList, will I need to grab the first LI's ID in a different way? ...

CSS selector not working ?

Hey guys, thanks in advance for any help or input. I am having trouble understanding CSS selectors and i have read the docs.. I am trying to refer to the UL with the id dropdown in my stylesheet. I was under the assumption that i was able to refer to any elements like: #dropdown ul { } This method however does not seem to work :s...

Is there any jquery simulators where I can practice usage of selectors

Hi all, I tried to search on net but I couldn't find any jquery simulators. By simulator I mean a page where I can write jquery code and see what it's executing, what is selected, how jquery selectors work etc. Is there anything similar on net? Thanx Marko ...

Weird child selector behavior...

Well, I finally decided to totally drop IE6. It's great. First big benefit which comes with this decision is child selectors. So I started to use them for my nested drop-down menus for the first time and expected it to be a breeze. But... here's the code: <style> body { color:#000; } ul.top > li { color:red; } <ul class="...

Set button action dynamicly

Hi, I have a few buttons in my view which work as a slideshow, every few seconds buttons change their appearance. On button click I open UIWebView and load a page, I need to change the target (url) of each button when they change their appearance. What is the easiest way to do it? I can't change buttons' tags as my slideshow based on t...

Which is better practice in CSS - single generic selector in multiple locations or multiple specific selectors?

Hi all, Which is better practice? .listing { some attributes:some values;} applied to multiple locations (e.g. search results, category listing) or .search-list, .category-list, .other-list { some attributes:some values;} It seems to me that the second option provides more flexibility for future changes to style without chan...

Can an Android <selector> be based on an object's state instead of a view's state?

I think this is a pretty simple question but I'm having trouble finding the answer out there... I'm developing an android application (currently developing against v1.5 API) and one of the activities use a ListView. I want to be able to set the properties of each List Item based on the state of an in memory object rather than the state ...

CSS3/jQuery selector to style group of 2 rows via the :nt-child() selector

I have a <table> that the data is separated per 2 <tr>'s So i want to style the rows(each 2 rows) as zebra stripped, but each set of 2 should be styled. I am trying something like: tr:nth-child(3n+1), tr:nth-child(4n+1){background:#f7f7f7;} I would prefer a CSS3 solution, but if only jQuery can do it, that will be fine. Please see...

Selectors: Id vs. context

I use jQuery. I have been reading a lot about selector performance and optimizing our AJAX app. I am looking to improve my selector performance. I know all the jquery performance tips. I haven't found an exact answer to a question I have. I am using almost every current jquery performance tip and yet my app still seems to lag quite a bi...

How to bind jQuery events on multiple PREDECLARED jQuery objects

Hi, This is how to bind multiple events on a couple jQuery selectors: $('#selector1,.selector2').bind('event', function (e, ui) { // Stuff }); But! How do you bind on predeclared jQuery objects. Example: var jSelector1 = $('#selector1'); var jSelector2 = $('.selector2'); Because, the following doesn't work: jSelector1,jSelec...

jQuery dynamic selectors show div

I have a set of dynamic headings and hidden divs with the idea that when the user clicks on a heading it toggles the div underneath to show/hide the divs all have an id in the form "div_x" where x is dynamically generated Ive managed to use .each() to loop over all divs that begin with div_ and I can .split the x portion of the id, but...