Comments on: Extending jQuery’s selector capabilities https://j11y.io/javascript/extending-jquerys-selector-capabilities/ Sun, 22 Mar 2015 15:39:22 +0000 hourly 1 https://wordpress.org/?v=5.0.13 By: ChiangMai Guide And Tour https://j11y.io/javascript/extending-jquerys-selector-capabilities/#comment-296 Sun, 01 Nov 2009 01:45:50 +0000 https://j11y.io/?p=237#comment-296 Nice.., good information for selector extends

]]>
By: Trygve Andersen https://j11y.io/javascript/extending-jquerys-selector-capabilities/#comment-295 Thu, 03 Sep 2009 21:25:50 +0000 https://j11y.io/?p=237#comment-295 Should this work in IE7?

$(‘div.someClass:width(>500)’).remove();

I’ve noticed that IE7 appears to ignore the class selector and iterates though every DIV checking the width. Chrome & FF work fine. I fixed it by doing this…

$(‘div.someClass’).filter(‘:width(>500)’).remove();

Did I do something wrong?

]]>
By: WSPanic https://j11y.io/javascript/extending-jquerys-selector-capabilities/#comment-294 Wed, 29 Jul 2009 17:04:09 +0000 https://j11y.io/?p=237#comment-294 Wow… Great post. I was in need of a solution to check width of all elements in a given block and if greater than a specified width set them to that width if they exceed it. Your width selector example fits the bill…

Also your examples of using the ‘data’ function opened up my eyes to some possibilities.

]]>
By: endrew https://j11y.io/javascript/extending-jquerys-selector-capabilities/#comment-293 Thu, 16 Jul 2009 12:58:16 +0000 https://j11y.io/?p=237#comment-293 @Dan: $.data(this)

]]>
By: Dan https://j11y.io/javascript/extending-jquerys-selector-capabilities/#comment-292 Mon, 22 Jun 2009 22:55:31 +0000 https://j11y.io/?p=237#comment-292 Hi, I’m having trouble using this. As an aid to the my co-developer, I’d like to log the data of any element that has it – what am I doing wrong?

$(':data').each(
 function()
  {							
    console.info( $(this).data() );
  }
)
]]>
By: Pim https://j11y.io/javascript/extending-jquerys-selector-capabilities/#comment-291 Tue, 02 Jun 2009 18:44:10 +0000 https://j11y.io/?p=237#comment-291 @Anon,
Great thanks for the tip. I have added the regex support.
Thank you very much for the code/info.

]]>
By: Anon https://j11y.io/javascript/extending-jquerys-selector-capabilities/#comment-290 Fri, 29 May 2009 15:44:23 +0000 https://j11y.io/?p=237#comment-290 Hi Pim, you can add ~= operator for testing regular expression

case ‘~’: // regular expression
exp = querySplitted[1].substr(1,querySplitted[1].lastIndexOf(‘/’)-1);
modif = querySplitted[1].substr(querySplitted[1].lastIndexOf(‘/’)+1)
re = new RegExp( exp, modif);
return re.test(checkAgainst);
break;

]]>
By: PIm https://j11y.io/javascript/extending-jquerys-selector-capabilities/#comment-289 Tue, 26 May 2009 10:25:00 +0000 https://j11y.io/?p=237#comment-289 Great article and great selectors.
I especially like the :data() selector. However I needed one that allowed me to query for data objects which are specified like this:

$('elem').data('foo', {bar:'el', baz:{a:2, b:'hai'}, bla:'x'});

So I decided to write my own selector which allows for querying like this:

$('elem:data("foo.baz.b=hai")');

It does not support regexes like yours, however you can do ^= $= != *= like the attribute selectors.
You can have a look at the sourcecode here.

Thanks for the article as this was the article that thought me how to write :selectors in the first place. And inspired me how to create the selector.

]]>
By: Martin https://j11y.io/javascript/extending-jquerys-selector-capabilities/#comment-288 Thu, 12 Mar 2009 21:47:37 +0000 https://j11y.io/?p=237#comment-288 Great post. Really, really useful.

I just started using jquery in earnest in the last two weeks or so. I keep getting fascinated by the power of this lib.

I didn’t know it was so easy to extend the selectors. I came here searching with Google for a way to select elements with a certain. Like “find all divs with background-color: red”.

That is not AFAIK possible with jquery out of the box, but it seems to be simple to create such a selector!

Thanks a million!

]]>
By: Gonzalo Arreche https://j11y.io/javascript/extending-jquerys-selector-capabilities/#comment-287 Tue, 10 Feb 2009 17:41:21 +0000 https://j11y.io/?p=237#comment-287 very nice.. really useful.. thanx.. 😛

]]>