JavaScript

dział w budowie



Istnieją daw sposoby dołączenia jQuery do strony internetowej:


1. załączanie biblioteki jQuery z zewnętrznego serwera:

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</head>

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>

2. ściągnięcie jQuery do siebie i podpięcie jQuery lokalne

jquery.com/download

<head>
<script src="jquery-3.7.1.js"></script>
</head>

<head>
<script src="jquery-3.6.0.js"></script>
</head>

<head>
<script src="jquery-3.5.1.min.js"></script>
</head>


Wyszukiwanie elementów.


jQuery()
$() - jest to skrót od jQuery()

$('li.hot')

Funkcja jQuery() ma jeden parametr: selektor stylu CSS.
Przedstawiony tutaj selektor wskazuje wszystkie elementy <li>, których wartością atrybutu class jest hot.


podstawowa składnia: $(selector).action()
   A $ sign to define/access jQuery
   A (selector) to "query (or find)" HTML elements
   A jQuery action() to be performed on the element(s)


$("selector").action()
$("*").hide() ukryj wszystkie elementy
$(this).hide() ukrywa bieżący element
$("p").hide() ukrywa wszystkie elementy <p>
$(".test").hide() ukrywa wszystkie elementy za pomocą class="test"
$("#test").hide() ukrywa element z id="test"
$("p.test").hide() ukryj wszystkie elementy <p>, których atrybutu class="text"
$("p#test").hide() ukryj element <p>, którego atrybut id="test"