login  Naam:   Wachtwoord: 
Registreer je!
 Forum

Javascript klasse/methode schrijven en aanroepen (Opgelost)

Offline Martijn2008 - 01/09/2011 23:52
Avatar van Martijn2008PHP beginner Hallo allemaal,

Op deze website ben ik onderstaande javascript code tegengekomen. Graag zou ik deze code dynamisch willen maken, zodat ik de identifiers dynamisch kan setten door middel van 1 methode. Weet iemand hoe?

Dank alvast!

Martijn

  1. $(document).ready(function() {
  2. // hides the slickbox as soon as the DOM is ready
  3. $('#slickbox').hide();
  4. // shows the slickbox on clicking the noted link
  5. $('#slick-show').click(function() {
  6. $('#slickbox').show('slow');
  7. return false;
  8. });
  9. // hides the slickbox on clicking the noted link
  10. $('#slick-hide').click(function() {
  11. $('#slickbox').hide('fast');
  12. return false;
  13. });
  14. // toggles the slickbox on clicking the noted link
  15. $('#slick-toggle').click(function() {
  16. $('#slickbox').toggle(400);
  17. return false;
  18. });
  19. });

1 antwoord

Gesponsorde links
Offline Ontani - 02/09/2011 09:43
Avatar van Ontani Gouden medailleGouden medailleGouden medailleGouden medaille

-1
  1. function init(slickbox, showlink, hidelink, togglelink) {
  2.  
  3. // hides the slickbox as soon as the DOM is ready
  4. $('#'+slickbox).hide();
  5.  
  6. // shows the slickbox on clicking the noted link
  7. $('#'+showlink).click(function() {
  8. $('#'+slickbox).show('slow');
  9. return false;
  10. });
  11.  
  12. // hides the slickbox on clicking the noted link
  13. $('#'+hidelink).click(function() {
  14. $('#'+slickbox).hide('fast');
  15. return false;
  16. });
  17.  
  18. // toggles the slickbox on clicking the noted link
  19. $('#'+togglelink).click(function() {
  20. $('#'+slickbox).toggle(400);
  21. return false;
  22. });
  23.  
  24. }
  25.  
  26. $(document).ready(function() {
  27. init("slickbox", "slick-show", "slick-hide", "slick-toggle");
  28. });
Bedankt door: Martijn2008
Gesponsorde links
Je moet ingelogd zijn om een reactie te kunnen posten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.184s