Forum Moderators: open
<html>
<head>
<title>script.aculo.us example</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js"></script>
<script type="text/javascript">
function ProductSlide(element){
new Effect.toggle(element,'Blind', {duration:3});
}
</script>
</head>
<body>
<div onmouseover="ProductSlide('myimage');" onmouseout="ProductSlide('myimage');" style="height:102px;width:130px;position:relative;">
<div id="mydescription" style="position:absolute;z-index:-1">
<p>Hello</p>
</div>
<div id="myimage">
<img src="http://www.tutorialspoint.com/images/scriptaculous.gif" alt="script.aculo.us" />
</div>
</div>
</body>
</html>
var q = [];
function adjustQueue() {
// Remove the first item from the queue
q.splice(0,1);
// see if there are any items remaining in the queue
if (q.length > 0) {
doEffect(q[0].element, q[0].effect);
}
}
function doEffect(element, effect) {
new Effect[effect](element, {
duration:3,
afterFinish: adjustQueue
});
}
function ProductSlide(element, effect){
// Allow at most 2 effects in queue
if (q.length == 0) {
q.push({element:element, effect:effect});
doEffect(element, effect);
}
else if (q.length == 1) {
// An action is in queue / currently running
// queue up another one only if it is different
if (q[0].effect != effect) {
q.push({element:element, effect:effect});
}
}
else {
// An action is currently running, with another queued up.
// If the current effect is the same as the running effect, remove
// the queued up action. Otherwise, replace the queued up action
if (q[0].effect == effect) {
q.splice(1,1);
}
else {
q[1] = {element:element, effect:effect};
}
}
}
<div onmouseover="ProductSlide('myimage','SlideUp');" onmouseout="ProductSlide('myimage','SlideDown');" style="height:102px;width:130px;position:relative;float:left;margin-right:20px;">
<div id="mydescription" style="position:absolute;z-index:-1">
<p>Hello</p>
</div>
<div id="myimage">
<img src="http://www.tutorialspoint.com/images/scriptaculous.gif" alt="script.aculo.us" />
</div>
</div>
<div onmouseover="ProductSlide('myimage2','SlideUp');" onmouseout="ProductSlide('myimage2','SlideDown');" style="height:102px;width:130px;position:relative;float:left;margin-right:20px;">
<div id="mydescription" style="position:absolute;z-index:-1">
<p>Hello</p>
</div>
<div id="myimage2">
<img src="http://www.tutorialspoint.com/images/scriptaculous.gif" alt="script.aculo.us" />
</div>
</div>
var q = {};
function adjustQueue(element) {
// Remove the first item from the queue
q[element].splice(0,1);
// see if there are any items remaining in the queue
if (q[element].length > 0) {
doEffect(q[element][0].element, q[element][0].effect);
}
}
function doEffect(element, effect) {
new Effect[effect](element, {
duration:3,
afterFinish: function () {
adjustQueue(element);
}
});
}
function ProductSlide(element, effect){
// Create a queue for this element if it doesn't exist
if (typeof q[element] === "undefined") {
q[element] = [];
}
// Allow at most 2 effects in queue
if (q[element].length == 0) {
q[element].push({element:element, effect:effect});
doEffect(element, effect);
}
else if (q[element].length == 1) {
// An action is in queue / currently running
// queue up another one only if it is different
if (q[element][0].effect != effect) {
q[element].push({element:element, effect:effect});
}
}
else {
// An action is currently running, with another queued up.
// If the current effect is the same as the running effect, remove
// the queued up action. Otherwise, replace the queued up action
if (q[element][0].effect == effect) {
q[element].splice(1,1);
}
else {
q[element][1] = {element:element, effect:effect};
}
}
}
some other way of targeting the div without specifying an id?