|
Categorieën >
JavaScript
Javascript klasse/methode schrijven en aanroepen (Opgelost)
|
|
|
offline
|
PHP 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
$(document).ready(function() {
// hides the slickbox as soon as the DOM is ready
$('#slickbox').hide();
// shows the slickbox on clicking the noted link
$('#slick-show').click(function() {
$('#slickbox').show('slow');
return false;
});
// hides the slickbox on clicking the noted link
$('#slick-hide').click(function() {
$('#slickbox').hide('fast');
return false;
});
// toggles the slickbox on clicking the noted link
$('#slick-toggle').click(function() {
$('#slickbox').toggle(400);
return false;
});
});
$(document).ready(function() { // hides the slickbox as soon as the DOM is ready $('#slickbox').hide(); // shows the slickbox on clicking the noted link $('#slick-show').click(function() { $('#slickbox').show('slow'); return false; }); // hides the slickbox on clicking the noted link $('#slick-hide').click(function() { $('#slickbox').hide('fast'); return false; }); // toggles the slickbox on clicking the noted link $('#slick-toggle').click(function() { $('#slickbox').toggle(400); return false; }); });
|
1 antwoord
|
|
|
offline
|
   
Grafische Ninja
|
function init(slickbox, showlink, hidelink, togglelink) {
// hides the slickbox as soon as the DOM is ready
$('#'+slickbox).hide();
// shows the slickbox on clicking the noted link
$('#'+showlink).click(function() {
$('#'+slickbox).show('slow');
return false;
});
// hides the slickbox on clicking the noted link
$('#'+hidelink).click(function() {
$('#'+slickbox).hide('fast');
return false;
});
// toggles the slickbox on clicking the noted link
$('#'+togglelink).click(function() {
$('#'+slickbox).toggle(400);
return false;
});
}
$(document).ready(function() {
init("slickbox", "slick-show", "slick-hide", "slick-toggle");
});
function init(slickbox, showlink, hidelink, togglelink) { // hides the slickbox as soon as the DOM is ready $('#'+slickbox).hide(); // shows the slickbox on clicking the noted link $('#'+showlink).click(function() { $('#'+slickbox).show('slow'); return false; }); // hides the slickbox on clicking the noted link $('#'+hidelink).click(function() { $('#'+slickbox).hide('fast'); return false; }); // toggles the slickbox on clicking the noted link $('#'+togglelink).click(function() { $('#'+slickbox).toggle(400); return false; }); } $(document).ready(function() { init("slickbox", "slick-show", "slick-hide", "slick-toggle"); });
|
Je moet ingelogd zijn om een reactie te kunnen posten.
|
|
|