Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6093355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:33:00+00:00 2026-05-23T12:33:00+00:00

I am using http://www.antiyes.com/jquery-blink-plugin for blinking images on my document. Code of that plugin

  • 0

I am using http://www.antiyes.com/jquery-blink-plugin for blinking images on my document.

Code of that plugin is

(function($)
{
  $.fn.blink = function(options)
  {
     var defaults = { delay:500 };
     var options = $.extend(defaults, options);

     return this.each(function()
     {
        var obj = $(this);
        setInterval(function()
        {
            if($(obj).css("visibility") == "visible")
            {
                $(obj).css('visibility','hidden');
            }
            else
            {
                $(obj).css('visibility','visible');
            }
        }, options.delay);
    });
  }
}(jQuery))

However I want to stop blinking of a particular image when I click on it. Currently I am doing it by modifying the code as follows

    (function($) {
        $.fn.blink = function(options) {
            var defaults = { delay: 500, blinkClassName: 'blink' };
            var options = $.extend(defaults, options);

            return this.each(function() 
            {
                var obj = $(this);

                setInterval(function() 
                {
                    if ($(obj).attr('class').indexOf(options.blinkClassName) > -1) 
                    {
                        if ($(obj).css("visibility") == "visible")
                        {
                            $(obj).css('visibility', 'hidden');
                        }
                        else 
                        {
                            $(obj).css('visibility', 'visible');
                        }
                    }
                    else 
                    {
                        if ($(obj).css("visibility") != "visible") 
                        {
                            $(obj).css('visibility', 'visible');
                        }
                    }
                }, options.delay);
            });
        }
    } (jQuery))  

I think there must be some better way to do it (perhaps using jquery data()) but unable to figure it out how to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:33:01+00:00Added an answer on May 23, 2026 at 12:33 pm

    jQuery’s data method is easy to use. The key fact here is that setInterval returns a value. This value is a number that identifies the interval. You can supply this identifier to clearInterval to stop the interval occuring.

    So your code will look something like this:

    return this.each(function()
    {
        var obj = $(this);
        var intervalID = setInterval(function()
        {
            var isVisible = obj.data('blink-visible');
            obj
               .css('visibility', isVisible ? 'hidden' : 'visible')
               .data('blink-visible', !isVisible);
        }, options.delay);
        obj.data('blink-interval', intervalID);
    });
    

    Then you could make a stopBlink method:

    $.fn.stopBlink = function() {
        return this.each(function() {
            var $el = $(this);
            var intervalID = $el.data('blink-interval');
            if (intervalID) {
                clearInterval(intervalID);
                $el.removeData('blink-interval');
                $el.css('visibility', 'visible');
            }
        });
    };
    

    Several other notes:

    1. .css('visibility', 'visible') is a verbose way of doing this. You can use the toggle method: this hides the element if it is currently visible and shows it if it is hidden. This is what I have done above.
    2. You don’t need to wrap obj in $(). obj is already a jQuery selection (it was created with $(this), so the extra wrap is entirely unnecessary.
    3. Think very hard about using blink functionality. It is obtrusive and frequently annoying, and can have health consequences for people with epilepsy.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using http://www.jankoatwarpspeed.com 's expand a row jQuery code (Link to the creator's site)
i am using http://www.asual.com/jquery/address/ plugin and trying to parse some url, this is what
I'm using http://www.steamdev.com/zclip/#usage to copy some text to the clipboard and that code is
I'm using the Enerjy ( http://www.enerjy.com/ ) static code analyzer tool on my Java
I'm using this plugin: http://www.jeremymartin.name/projects.php?project=kwicks And my code follows this example: http://www.jeremymartin.name/examples/kwicks.php?example=7 I'm using
I am looking into using http://www.asual.com/jquery/address/ , but I am wondering how it effects
I'm using http://www.chicowebdesign.com/blog/2010/10/21/updated-jquery-multiple-background-plug-in/ As they state to, but in IE the multiple backgrounds do
I have been trying to play a video that was converted using http://www.mirovideoconverter.com/ to
I am using http://www.uploadify.com/ but when I upload images with character (čžćšđ) like čžćšđ.jpg
I am using http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ for validation. Validation rules are defined in a following way:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.