[JavaScript] RegEx verwenden

Variante 1

let str = '123456';
let regex = /^(\d{6})?$/;

// RegEx testen
// Besp: String muss aus 6 Zahlen bestehen
if (regex.test(str))
{
    console.log('match');
}
else
{
    console.log('no match');
}

Variante 2

let str = '123456';

// RegEx testen
// Besp: String muss aus 6 Zahlen bestehen
if (/^(\d{6})?$/.test(str))
{
    console.log('match');
}
else
{
    console.log('no match');
}

[AJAX] $.post()

Allgemein

$.post(URL, data, callback); 

Beispiel

// https://www.w3schools.com/jquery/jquery_ajax_get_post.asp
$("btn1").click(function(){
    // url
    $.post("btn1_post.php",
    // data
    {
        data1: "some data1",
        data2: "some data2"
    },
    // callback
    function(data, status){
        console.log("Data: " + data);
        console.log("Status: " + status);
    });
}); 

[AJAX] $.get()

Allgemein

$.get(URL, callback); 

Beispiel

// https://www.w3schools.com/jquery/jquery_ajax_get_post.asp
$("btn1").click(function(){
    // url
    $.get("btn1_get.php",
    // callback
    function(data, status){
        console.log("Data: " + data);
        console.log("Status: " + status);
    });
}); 

[jQuery] Eventhandler entfernen

// https://api.jquery.com/click/

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>jQuery Button-Klick</title>
</head>
<body>
  <button id="btn1">Klick mich!</button>
</body>
</html>

// Button mit id="btn1": Eventhandler registrieren
$("#btn1").on("click", function(evt){
  console.log(evt.target);
  $(this).fadeOut();
});

// Button mit id="btn1": Eventhandler deregistrieren
$("#btn1").off("click");

[jQuery] Eventhandler registrieren

// https://www.w3schools.com/jquery/jquery_events.asp

// Beispiel ($(document).ready)
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
// mehrere Eventhandler für ein Objekt registrieren
$(document).ready(function(){
    $("#p1").on({
    	mouseenter : function(){
        $(this).html("Entered");
    	},
    	mouseleave : function(){
        $(this).html("Left");
    	}
		})
});
</script>
</head>
<body>