jQuery macht globale Variable

Funktionsübergabea_href = $(this).attr('href'); Wert zu globala_href, machena_href="home"

var a_href; 

    $('sth a').on('click', function(e){
        a_href = $(this).attr('href');

          console.log(a_href);  
         //output is "home"

        e.preventDefault();
    }

console.log(a_href);  
//Output is undefined 

Antworten auf die Frage(3)

Ihre Antwort auf die Frage