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

  • Home
  • SEARCH
  • 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 4066348
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:07:15+00:00 2026-05-20T16:07:15+00:00

I have the following inline javascript, im using a jquery countdown plugin to display

  • 0

I have the following inline javascript, im using a jquery countdown plugin to display time remaining.

this code exists with each “Comment” on the page, hence it is repeating multiple time on the page. How can I make this external? and avoid the repetition?

im using .nt mvc razor and attaching id.

<script type="text/javascript">
    $(function () {
    var dateLeft = new Date(@(item.UnixTicks));
    $('#countdown-@(item.ID)').countdown({until: dateLeft, format:'MS', onExpiry: liftOff, onTick: watchCountdown}); 

    function liftOff() { 
        alert('We have lift off!'); 
    } 

    function watchCountdown(periods) { 
        $('#monitor-@(item.ID)').text('Just ' + periods[5] + ' minutes and ' + 
            periods[6] + ' seconds to go'); 
    }
    });
</script> 
  • 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-20T16:07:15+00:00Added an answer on May 20, 2026 at 4:07 pm

    You can put the UnixTicks into an attribute in the comment, give all of the comments a class="comment", and loop over them:

    $('.Comment').each(function() { 
        var dateLeft = new Date(parseInt($(this).attr('data-unixticks'), 10));
        ...
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following inline Javascript code: <a href=javascript:{ document['example'].src = 'cube.png'; document.getElementById('constructor').innerHTML =
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,
I have the following code: what i want is using css put the MYIMAGE
I have the following markup with inline javascript and would like to change it
i have the following form <form action=#!/search/ method=get style=display:inline; id=hdr_q> <table cellpadding=0 cellspacing=0> <tr><td><input
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
Suppose I have following string: String asd = this is test ass this is
Just a (hopefully) quick question, I have the following HTML code: <tr> <td><img src=img/icons/file_pdf.png></td>
I have following HTML code: <section class=indent-1> <!-- Section 1 --> <section> <div>Some content</div>

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.