Member-only story

jQuery — Find Elements and Finish Animations

John Au-Yeung
3 min readDec 30, 2020

--

Photo by JOSHUA COLEMAN on Unsplash

jQuery is a popular JavaScript for creating dynamic web pages.

In this article, we’ll look at how to using jQuery in our web apps.

:file Selector

We can get the input with type file with the :file selector.

For example, if we have:

<form>
<input type="button" value="Input Button">
<input type="checkbox">
<input type="file">
<input type="hidden">
<input type="password">
<input type="radio">
<input type="reset">
<input type="submit">
<input type="text">
<select>
<option>Option</option>
</select>
<textarea></textarea>
<button>Button</button>
</form>

We can write:

$("input:file").css({
background: "yellow",
border: "3px red solid"
});

.filter()

The filter method lets us get the elements that match the select or pass a function test from a set of matched elements.

For example, if we have:

<ul>
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
<li>list item 4</li>
<li>list item 5</li>
<li>list item 6</li>
</ul>

We can get the li s that are in an even number position and add a red background to them by writing:

--

--

No responses yet