2016-07-22 20 views
1

Ich versuche den Fokus auf ein Ankerelement in einem versteckten div-Element zu legen, während ich auf einen anderen Ankerlink klicke. Ich habe einige Optionen wie .focus(), .focusin() ausprobiert. Aber nichts funktioniert.Den Fokus setzen, um in div nach der Show zu verankern?

Mein Code:

<script> 
    $(document).ready(function(){ 
     $("#clickShow").on('click', function(){ 
      $("#showDescription").show(); 
      $("#showDescription").find("a").focus(); 
     }); 
    }); 
</script> 
<div> 
    <a href="#" id="clickShow">View Hidden Text</a> 
</div> 

<div id="showDescription" style="display:none;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap <a href="#">Link Text</a> into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div> 

wollte ich wissen, was ich hier fehlt, um es getan?

Schätzen Sie Ihre geschätzte Hilfe.

Antwort

1

Eigentlich funktioniert es! Gebrauchte jquery 2.1.1

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<script> 
 
    $(document).ready(function(){ 
 
     $("#clickShow").on('click', function(){ 
 
      $("#showDescription").show(); 
 
      $("#showDescription").find("a").focus(); 
 
     }); 
 
    }); 
 
</script> 
 
<div> 
 
    <a href="#" id="clickShow">View Hidden Text</a> 
 
</div> 
 

 
<div id="showDescription" style="display:none;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap <a href="http://www.google.com">Link Text</a> into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>

EDIT: Versuchte in 1.11.1 zu ... seine Arbeits ... Vielleicht ist Ihr Problem ist etwas anderes

+0

Eigentlich meine Anwendung jQuery 1.11.1 Version. Sind das irgendwelche Möglichkeiten, dies als funktionales zu machen? – Maniram

+0

Auch in 1.11.1 versucht ... funktioniert es ... Vielleicht ist Ihr Problem etwas anderes – kukkuz