Guest User

Untitled

a guest
Aug 17th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. jQuery : show div by dynamic id
  2. <ul>
  3. <li><a href="#" class="service-chooser" id="ubuntu-one">Ubuntu One</a></li>
  4. <li><a href="#" class="service-chooser" id="ftp">FTP account</a></li>
  5. </ul>
  6.  
  7. <!-- these div are hidden -->
  8. <div id="ubuntu-one-form" class="hide">
  9. Ubuntu One credential
  10. </div>
  11. <div id="ftp-form" class="hide">
  12. Ftp Crediental
  13. </div>
  14.  
  15. <script type="text/javascript">
  16. $(document).ready(function() {
  17.  
  18. $(".service-chooser").click(function() {
  19. var service = $(this).attr('id');
  20. var service-id = '#' + service + 'form';
  21.  
  22. $(service-id).show('slow', function() {
  23. // Animation complete.
  24. });
  25.  
  26. });
  27.  
  28. });
  29.  
  30. </script>
  31.  
  32. $(".service-chooser").click(function() {
  33. var service = this.id ; // Example ubuntu-one
  34. var service_id = '#' + service + '-form'; // Example #ubuntu-one-form
  35.  
  36. $(service_id).show('slow', function() {
  37. // Animation complete.
  38. });
  39. });
  40. });
  41.  
  42. $(".service-chooser").click(function() {
  43. var service = $(this).attr('id');
  44. var service_id = '#' + service + '-form';
Add Comment
Please, Sign In to add comment