This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Jquery muckt rum
#1
Aus welchen Grund läuft dieser Code nicht ? Habe ich was vergessen ? Habe alles so gemacht wie es in der  Doku steht.
Falls mal einer Zeit findet wäre ich dankbar für eine Antwort. Besten Dank.

<!doctype html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <style>
 div {
    color: red;
  }
  </style>
  <script src="https://code.jquery.com/jquery-3.2.1.js"></script>
</head>
<body>
 <div id="target">
  Click here
</div>
<script>


$( "#target" ).toggle(function() {
  alert( "First handler for .toggle() called." );
}, function() {
  alert( "Second handler for .toggle() called." );
});
</script>

</body>
</html>
Zitieren
#2
toggle() ist ab jQuery irgendwas veraltet. Wenn das unbedingt laufen soll, musst du eine ältere Version von jQuery laden.

Edit. Ab jQuery 1.8 gibt es toggle() so nicht mehr https://api.jquery.com/toggle-event/

Benutzt nee ältere Version als 1.8 oder las dir was anderes einfallen, um einen Button doppelt zu benutzen
Als Lösung markieren Zitieren
#3
Hier der Code den du suchst, viel Spaß damit 

<button class="target">Click here</button>

$(document).ready(function ($) {
      function a() { alert("First handler for .toggle() called."); }
      function b() { alert("Second handler for .toggle() called."); }
      var ab = [a, b];

      $('.target').click(function () {
        ab.reverse()[1]();
      });
    });
Als Lösung markieren Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste