JSFiddle - React, Tailwind, and code Playground
by mjmitche
HTML
<ul id="list1">
<li class="a">item 1</li>
<li class="a">item 2</li>
<li class="b">item 3</li>
<li class="b">item 4</li>
</ul>
<p class="a">This is paragraph 1</p>
<p id="para1">This is paragraph 2</p>
<p class="b">This is paragraph 3</p>
<p id="para2">This is paragraph 4</p>
CSS
.a { color: Navy; }
.b { color: Maroon; }
JavaScript
$("document").ready(function() {
// Inspect the length and size() of a result set
alert("There are " + $("p").length + " <p> elements");
// use the get() and get(index) to retrieve DOM elements
var elems = $("li").get();
alert("There are " + elems.length + " <li> tags");
alert($("li").get(0));
// use the find function
$("ul").find("li.b").css("border", "3px solid red");
// use the each function
var leftmargin = 0;
var border = 3;
$("p").each(function() {
$(this).css("border", border+"px solid red");
$(this).css("margin-left", leftmargin);
border += 2;
leftmargin += 10;
});
});