Questions tagged [sizzle]

Sizzle is a JavaScript CSS selector engine.

Sizzle is a pure-JavaScript CSS selector engine. CSS 3 selectors are supported, plus an additional set of custom selectors.

Resources

165 questions
728
votes
6 answers

Wildcards in jQuery selectors

I'm trying to use a wildcard to get the id of all the elements whose id begin with "jander". I tried $('#jander*'), $('#jander%') but it doesn't work.. I know I can use classes of the elements to solve it, but it is also possible using…
tirenweb
  • 30,963
  • 73
  • 183
  • 303
46
votes
3 answers

What's the use of Array.prototype.slice.call(array, 0)?

I was just browsing Sizzle's source code and I came across this line of code: array = Array.prototype.slice.call( array, 0 ); I looked up what the function is, but I came to the conclusion that it just returns all elements of the array starting…
pimvdb
  • 151,816
  • 78
  • 307
  • 352
44
votes
7 answers

How is the jQuery selector $('#foo a') evaluated?

As a example of jQuery code (https://coderwall.com/p/7uchvg), I read that the expression $('#foo a'); behaves like this: Find every a in the page and then filter a inside #foo. And it does not look efficient. Is that correct? And if yes, how…
Afshin Mehrabani
  • 33,262
  • 29
  • 136
  • 201
38
votes
6 answers

jQuery Optimization/Best Practices

Ok saddle up cowboys, because this is going to be a long one. I have been spending the morning going through some of my old code and I'm left wondering about best practices and optimzation. In order to avoid a ride down subjective lane I'll just…
HurnsMobile
  • 4,341
  • 3
  • 27
  • 39
35
votes
9 answers

Dynamic Adsense Insertion With JavaScript

I can't believe how hard this is to find, but even in the Google developer docs I can't find it. I need to be able to dynamically, only with JavaScript insert adsense. I also looked on StackOverflow and some others have asked this but no response.…
Oscar Godson
  • 31,662
  • 41
  • 121
  • 201
32
votes
1 answer

Why do functional pseudos such as :not() and :has() allow quoted arguments?

Apparently, as I've discovered while commenting on another answer, jQuery (rather its underlying selector engine Sizzle) lets you quote the argument to the :not() selector as well as the :has() selector. To…
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
20
votes
4 answers

How and what benefit can I take by including Sizzle.js along with jquery1.4.2?

latest jquery 1.4.2 downloaded from jquery.com comes with Sizzle.js also. How and what benefit can I take from included Sizzle.js? Is Sizzle.js a standalone library? Why it's included inside jquery library, for what purpose? /*! * jQuery…
Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852
19
votes
2 answers

decoupling jquery, sizzle?

Does anyone have experience / insight re: decoupling jquery / sizzle? this is for general interest, but here's the scenario that triggered my question: ..i already have jquery in the project. wanted to try out http://ecsstender.org/, which…
zack
  • 3,198
  • 2
  • 35
  • 51
16
votes
2 answers

Is it possible to create custom jQuery selectors that navigate ancestors? e.g. a :closest or :parents selector

I write a lot of jQuery plugins and have custom jQuery selectors I use all the time like :focusable and :closeto to provide commonly used filters. e.g. :focusable looks like this jQuery.extend(jQuery.expr[':'], { focusable: function (el, index,…
iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202
15
votes
5 answers

How to get a specific jQuery item from a list of items?

I have this:
  • first
  • second
  • third
  • fourth
Then I select it all with jQuery: $('ul').find('li'); or $('ul li'); How can I, from those two jQuery selectors get the, for instance only second…
user798596
13
votes
1 answer

Is there a Sizzle/jQuery selectors implementation in C#?

I need to be able to simply specify elements from html in my C# application. I would just use Linq to Sql but this needs to be configurable/serializable to a string. I could of course use XPath but something like Sizzle at this point is just so much…
George Mauer
  • 117,483
  • 131
  • 382
  • 612
12
votes
4 answers

jQuery Syntax error, unrecognized expression: [name=Basics.Gender]

I am upgrading from jQuery 1.4.4 to jQuery 1.7.2 and I get a syntax error. I think its due to the '.' in the Basics.Gender part of the selector. $('[name=Basics.Gender]') Anyone have any suggestions on how to fix…
superlogical
  • 14,332
  • 9
  • 66
  • 76
11
votes
1 answer

How to select an element which doesn't have a specific class name, using jQuery?

How could a Commando, like myself, select an element witch does not have a class named "active", using the infamous and powerful jQuery Sizzle CSS and everything else - Selector? I've tried with: $('a[class!="active"]').etc(); But it gives no…
user798596
11
votes
6 answers

jQuery Selectors, efficiency

I have been reading more lately about the efficiency of the different selector engines. I know that jQuery uses the Sizzle engine and this blog post about some jQuery stuff mentioned that the Sizzle engine will break apart your selector into an…
Chad
  • 19,219
  • 4
  • 50
  • 73
11
votes
4 answers

Get iframe contents with a jquery selector

Is there anyway to access an iframe's contents via a selector? Something like this: $("iframe::contents .my-foo") I'm constantly accessing an iframe's contents for a project I'm currently working on and $("iframe").contents().find(".my-foo") is…
Xavi
  • 20,111
  • 14
  • 72
  • 63
1
2 3
10 11