निम्न मार्कअप को देखते हुए:
<div id="marquee">My Text</div>
दोहराव के लिए, मैं कुछ इस तरह करते हैं:
$("#marquee").wrapInner("span"); // wrap "My Text" with a new span
$("#marquee").append($("#marquee span").clone().hide()); // now there are two spans with "My Text"
स्थानांतरण और फैला अदला-बदली है बहुत आसान। यहां एक पूर्ण कार्यात्मक उदाहरण दिया गया है:
$(function() {
var marquee = $("#marquee");
marquee.css({"overflow": "hidden", "width": "100%"});
// wrap "My Text" with a span (old versions of IE don't like divs inline-block)
marquee.wrapInner("<span>");
marquee.find("span").css({ "width": "50%", "display": "inline-block", "text-align":"center" });
marquee.append(marquee.find("span").clone()); // now there are two spans with "My Text"
// create an inner div twice as wide as the view port for animating the scroll
marquee.wrapInner("<div>");
marquee.find("div").css("width", "200%");
// create a function which animates the div
// $.animate takes a callback for when the animation completes
var reset = function() {
$(this).css("margin-left", "0%");
$(this).animate({ "margin-left": "-100%" }, 3000, 'linear', reset);
};
// kick it off
reset.call(marquee.find("div"));
});
See it in action।
अस्वीकरण:
मैं किसी भी पेशेवर वेबसाइट के लिए इस सलाह नहीं देते। हालांकि, यह उपयोगी हो सकता है यदि आप 1 99 0 के रेट्रो को पुन: उत्पन्न करने की कोशिश कर रहे हैं।
लेट्स पार्टी की तरह 1995 है! – Kevin
आपकी झुकाव बिल्कुल सही है। –
मैंने अभी इसके लिए एक प्लगइन बनाया है। आशा है कि इस मदद करता है :) https://github.com/aamirafridi/jQuery-Marquee –