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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:13:51+00:00 2026-05-28T22:13:51+00:00

$.each(obj,function(key,value) {}) I am a newbie of jquery, i know there are two ways

  • 0
$.each(obj,function(key,value) {})

I am a newbie of jquery, i know there are two ways to write the structure like this:

$('document').ready(function(){}); or     $(function(){});

why $.each() put . behind $ rather than $(each())

`

  • 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-28T22:13:52+00:00Added an answer on May 28, 2026 at 10:13 pm

    In JavaScript (and remember, jQuery is a JavaScript library that doesn’t do anything you couldn’t do yourself in JavaScript) functions are a type of object. Hopefully you already know how to define and call a JavaScript function, with the following syntax that is similar to many other languages:

    function myFunction() {
       alert("This is myFunction");
    }
    
    myFunction();      // alerts "This is myFunction"
    

    But because a function is also an object it can have other properties:

    myFunction.someProperty = "test";
    alert(myFunction.someProperty);    // alerts "test"
    

    In that example someProperty was a simple string, but you can also create properties that refer to functions, i.e., that are methods:

    myFunction.someMethod = function() {
                              alert("This is someMethod");
                            };
    
    myFunction.someMethod();    // alerts "This is someMethod"
    

    The jQuery syntax you have asked about is essentially the same thing as above, except at first it seems more complicated because the $() function does different things depending on the type of the parameter(s) you pass to it. But

    $(function(){});
    // is equivalent to my example
    myFunction();
    
    $.each();
    // is equivalent to my example
    myFunction.someMethod();
    

    Some jQuery code gets a bit more confusing because in many cases jQuery function calls return a “jQuery object” that itself has a bunch of methods defined.

    $(document)
    // returns a jQuery object that has a "ready" method so you can say
    $(document).ready();
    // which is equivalent to 
    var doc = $(document);
    doc.ready();
    

    Many jQuery methods return the same type of jQuery object, so you can chain calls together:

    $('div').hide().fadeIn().fadeOut().show();
    

    The last .show() at the end also returns a jQuery object but we aren’t doing anything with it.

    These concepts are all a standard part of the JavaScript language, so I suggest you work your way through a good JavaScript tutorial. If you look at the jQuery source code (i.e., the content of jQuery.js) there is a lot of confusing code to digest, but if you start by playing around with something simple like my first few examples above you’ll get the hang of it.

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

Sidebar

Related Questions

I have this function: function myfunc(obj, properties, value) { $.each(properties, function(i, key) { var
I have this code: $.each(properties, function(i, key) { obj.css({'-webkit-border-' + key + '-radius': value+'px',
function countJSONObjByKeyValue(obj, key, value) { var countJSONShows = 0; $.each(obj, function(i, item) { if(obj[i].key
I have this piece of code: this.json.each(function(obj, index) { var li = new Element('li');
I am trying to perform jQuery each function on something like: RelatedDoc: [ {
for (var key in obj[i]) { dataDump[key] = textField.value; textField.addEventListener('change', function (e) { dataDump[key]
For example I have this plugin code: jQuery.fn.keys = function(obj) { var keys =
I have this piece of code: ['design','finish','grills'].each(function(type) { this.json.type.each(function(obj, index) { console.log(obj); }); }.bind(this));
Each of these variables has an integer value. But this syntax is not valid
I'm new to jQuery and i'd like to fadeTo() this selection to give user

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.