Ankündigung

Einklappen
Keine Ankündigung bisher.

Fokus in Colorbox auf Input Feld setzen [ERLEDIGT]

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Fokus in Colorbox auf Input Feld setzen [ERLEDIGT]

    Wie kann ich in der Colorbox den Fokus auf ein Input Feld setzen?
    Normalerweise geht das ja mit autofocus oder $('#ID').focus()

    Beides bleibt ohne Funktion. Wer weiß Rat?
    HTML-Code:
    <!DOCTYPE html>
    <html>
     <head>
      <title>test</title>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
      <script src="../jquery.colorbox-min.js"></script>
      <link rel="stylesheet" href="colorbox.css" />
      <script>
       $(document).ready(function(){
        $('#test').focus();
        $(".ajax").colorbox();
       });
      </script>
     </head>
     <body>
      <p><a class='ajax' href="ajax.php">Ajax</a></p>
     </body>
    </html>
    HTML-Code:
    <div style="height:135px; width:380px; padding:30px 10px;">
     <form method="post" action="">
      <input type="text" name="test" id="test">
      <input type="submit">
     </form>
    </div>

  • #2
    indem du den Fokus setzt, nachdem das Formular geladen wurde, nicht vorher.

    Kommentar


    • #3
      Wie meinst Du das?
      Ich hatte es so:
      HTML-Code:
      <div style="height:135px; width:380px; padding:30px 10px;">
       <form method="post" action="">
        <input type="text" name="test" id="test">
        <script language="javascript" type="text/javascript">
         $('#test').focus();
        </script>
        <input type="submit">
       </form>
      </div>
      und so
      HTML-Code:
      <div style="height:135px; width:380px; padding:30px 10px;">
       <form method="post" action="">
        <input type="text" name="test" id="test" autofocus>
        <input type="submit">
       </form>
      </div>
      versucht.

      Kommentar


      • #4
        Nein, so meint er das nicht, baue einen event listener, öffne ColorBox und frage cbox_complete ab, dann setzt Du Deinen Fokus.

        Kommentar


        • #5
          Code:
          $(document).ready(function() {
           $(document).bind('cbox_complete', function(){
            $('#test').focus();
           });
           $(".ajax").colorbox();
          });
          Ich bedanke mich recht herzlich!

          Kommentar

          Lädt...
          X