I have a variable $obj which has $(".major_data .commitment_box .commitment") as its value. No I want to use some CSS Selectors on $obj. How can I use them?
Selectors I want to use: :not(:last-child).
My Code:
HTML:
<div class="major_data">
<div class="commitment_box">
<div class="commitment">
<p>Alex:</p>
<p>He's works great.</p>
</div>
<div class="commitment">
<p>Alex 1:</p>
<p>He's works great.</p>
</div>
<div class="commitment">
<p>Alex 2:</p>
<p>He's works great.</p>
</div>
<div class="commitment">
<p>Alex 3:</p>
<p>He's works great.</p>
</div>
<div class="commitment">
<p>Alex 4:</p>
<p>He's works great.</p>
</div>
</div>
</div>
CSS:
.major_data .commitment_box {
text-align: center;
height: 40px;
overflow: hidden;
}
.major_data .commitment_box .commitment p {
display: inline-block;
}
.major_data .commitment_box .commitment p:first-child {
font-weight: bold;
margin-right: 20px;
}
JS:
function tick() {
var $obj = $(".major_data .commitment_box .commitment");
$obj.first().delay(1000).fadeOut(function () {
$obj.first().insertAfter($obj.last());
tick();
});
}
tick();
Result:
Demonstration
My Question:
I want to target the :not(:last-child) of the $obj. I know I can do that by simply writing that whole big value of $obj but is that possible only using the variable $obj?
Thanks in advance.