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 1054271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:22:43+00:00 2026-05-16T17:22:43+00:00

Here is my jQuery: jQuery( document ).ready( function ( $ ) { $(‘ul li:first-child’).addClass(

  • 0

Here is my jQuery:

jQuery( document ).ready( function ( $ ) {
    $('ul li:first-child').addClass( 'first_item' );
    var className = $('.first_item').attr('id');
    alert('Date is:'+ className +'.');
});

And then this another section of jQuery, that im trying to contrust a variable in:

j(".refreshMe").everyTime(5000, function (i) {
    j.ajax({
        url: "test.php?latest=" + className + "",
        cache: false,
        success: function (html) {
            j(".refreshMe").html(html);
        }

Its this line:

url: "test.php?latest="+className+"",

Im trying to take the className variable and feed it into this line.

Can anyone suggest what im doing wrong here?

  • 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-16T17:22:44+00:00Added an answer on May 16, 2026 at 5:22 pm

    Looks to me that the problem is simply the fact that you declared “className” inside that “ready” handler, so it’s not visible to the other code.

    Pull the declaration out of there and make it global (though see below):

    var className;
    

    Then remove var on the line in the “ready” handler

    className = $('.first_item').attr('id');
    

    Now, global variables like that certainly work, but it’s kind-of ugly. It might be nicer if you just moved that “everyTime” thing inside the same “ready” handler and keep the variable local.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the JQuery: $(document).ready(function() { $('#autosave').click(function() { var url = window.location.pathname; $postData =
Here's my fiddle: http://jsfiddle.net/mikeritter/prsfM/28/ Here's my jQuery: $(document).ready(function(){ function howdy(n){ alert('Howdy '+n+'!'); } function
so basically here is my script: http://jsfiddle.net/JJFap/42/ Code - jQuery(document).ready(function() { var rel =
Here's my jQuery snippet $(document).ready(function() { $(#button).click(function(e) { $(body).append('Source:CIA World Factbook'); }); }); I
I'm using jquery to submit my form (with id #myForm here) as follows: $(document).ready(function()
jQuery(document).ready(function($) { $('.c5sliderSelect').change(function() { alert('change clicked'); }); }); When I change the select list
Here is client Side code: jQuery(document).ready(function(){ jQuery(#list).jqGrid({ url:'example.php', datatype: 'xml', mtype: 'GET', colNames:['Inv No','Date',
Here is the JQGrid setup information jQuery(document).ready(function () { jQuery(#list).jqGrid({ url: '/TabMaster/GetGridData', datatype: 'json',
Just curious... I begin my jquery code with this: jQuery(document).ready(function($) { /*code here*/ })
jQuery(document).ready(function(){ // ok im geting the value here maybe i should make it in

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.