The following code was taking from the timers jQuery plugin demo. I don't understand what is happening in the selector in line 2. It seems it is selecting the p element, but then what is the second argument after the comma - demos
- there for?
jQuery:
var demos = $("div.wrapper div.demos");
$(".uncontrolled-interval p", demos).everyTime(1000,function(i) {
$(this).html(i);
});
HTML:
<div class="wrapper">
<div class="demos">
<div class="uncontrolled-interval">
<p>I am transient... *sigh*</p>
</div>
</div>
</div>
Thanks
It specifies the context of the search. Basically a filter.
http://api.jquery.com/jQuery#expressioncontext
So in this example it searches the demos
element for .uncontrolled-interval p
. If you have this markup, it would still only select the one in demos
.
<div class="wrapper">
<div class="uncontrolled-interval">
<p>I am transient... *sigh*</p> //Will not select
</div>
<div class="demos">
<div class="uncontrolled-interval">
<p>I am transient... *sigh*</p> //Will select
</div>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With