public
Last active

jQuery.sub examples

  • Download Gist
with-jquery.sub.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<!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>
with-jquery.sub.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12
(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()));
without-jquery.sub.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<!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>
without-jquery.sub.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14
(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));

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

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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.