1$(".class").click(function(){
2 $(this).find(".subclass").css("visibility","visible");
3});
1$(".txtClass") => getElementsByClassName()
2
3$("#childDiv2 .txtClass") => getElementById(),
4 then getElementsByClassName()
5
6$("#childDiv2 > .txtClass") => getElementById(),
7 then iterate over children and check class
8
9$("input.txtClass") => getElementsByTagName(),
10 then iterate over results and check class
11
12$("#childDiv2 input.txtClass") => getElementById(),
13 then getElementsByTagName(),
14 then iterate over results and check class
1// first make sure that jQuery is linked to your site or page
2// add it in the <body> section before the closing body tag </body>
3// <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
4$(".yourClassName");
5
6// you can also use classes that have dashes
7$(".your-class-name");
8
9// you can now use the selected element:
10// for example to change color
11$(".yourClassName").css("color", "red");
12
13// change backgound color
14$(".yourClassName").css("backgroud", "blue");
15
16// change text
17$(".yourClassName").text("Hey World!!!");
18
19// change link attribute
20$(".yourClassName").attr("href", "https://google.com");
21
22// check attributes (href, src, alt etc...)
23$(".yourClassName").attr("href");