Skip to content

Instantly share code, notes, and snippets.

@lukemorton
Created February 15, 2011 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukemorton/827617 to your computer and use it in GitHub Desktop.
Save lukemorton/827617 to your computer and use it in GitHub Desktop.
jQuery.sub examples
<!doctype html>
<html>
<head>
<title>Testing jQuery.sub()</title>
</head>
<body>
<div class="example">Testing</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script src="with-jquery.sub.js"></script>
<script>
jQuery(function ($) {
$('.example')
.fadeOut()
.delay(1000) // Does not append paragraph
.fadeIn()
.myPlugin()
.fadeOut()
.delay(1001) // Does append paragraph
.fadeIn();
$('.example')
.fadeOut()
.delay(1002) // Does not append paragraph still
.fadeIn();
});
</script>
</body>
</html>
(function ($, myPlugin) {
myPlugin.fn.delay = function (delay, queueName) {
$('body').append('<p>Delaying for ' + delay + '</p>');
return $.fn.delay.call(this, delay, queueName);
};
$.fn.myPlugin = function () {
return myPlugin(this);
};
}(jQuery, jQuery.sub()));
<!doctype html>
<html>
<head>
<title>Testing jQuery.sub()</title>
</head>
<body>
<div class="example">Testing</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script src="without-jquery.sub.js"></script>
<script>
jQuery(function ($) {
$('.example')
.fadeOut()
.delay(1000) // Does not append paragraph
.fadeIn()
.myPlugin()
.fadeOut()
.delay(1001) // Does append paragraph
.fadeIn();
$('.example')
.fadeOut()
.delay(1002) // Does not append paragraph still
.fadeIn();
});
</script>
</body>
</html>
(function ($) {
$.fn.myPlugin = function () {
this.delay = function (delay, queueName) {
$('body').append('<p>Delaying for ' + delay + '</p>');
return $.fn.delay.call(this, delay, queueName);
};
return this;
};
}(jQuery));
@lukemorton
Copy link
Author

Isn't using jQuery.sub() just over complicating matters? I'm not sure I see the benefits in this particular instance.

@nakataaaa
Copy link

hello,
i'm trying to mix a video whit subtitles in a wamp server i dont knwo what im doing wrong....cause it simples play the video but srt file misse...
Do u have any kind of example, tutorial or something to help me out?

Chears from portugal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment