jQuery is the most popular framework of JavaScript. Different browsers execute JavaScript, use different techniques to display results in the browser. jQuery brings these capabilities to a unique format. As a result, JavaScript code can be easily written here. jQuery is also called cross-browser JavaScript library.
Many browsers “: nth-child (n)” does not support Pseudo-class, we can easily support it through jQuery.
Example Code:
<
html
>
<
head
>
<
title
> www.mydemo.com</
title
>
<
style
type
=
"text/css"
>
.arif{
color:blue;
}
</
style
>
</
head
>
<
body
>
<
ul
class
=
"emphasis"
>
<
li
>item 1</
li
>
<
li
>item 2</
li
>
<
li
>item 3</
li
>
</
ul
>
</
body
>
</
html
>
$ (‘Ul.emphasis’) children (‘li’). First (). AddClass (‘arif’); In this case, the arif class will be added to the first li under ul.emphasis.
<style type = “text / css”>
ul li: nth-child (1) {
color: blue;
}
</ style>
The same work will be done by this css. But the difference is that css code will not support many browsers, jQuery code will support all browsers.
immaculate post