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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:29:44+00:00 2026-05-28T20:29:44+00:00

With jQuery latest one: <script src=http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js></script> <script src=http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js></script> Could someone explain what are the

  • 0

With jQuery latest one:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js"></script>

Could someone explain what are the differences between:

$(document).ready(function () {
  $('.produit').append('<img src="img.png" alt="altimg" />');
});

and:

$(document).ready(function () {
  $('.produit').append($('img').attr({ 'src':'img.png', 'alt':'altimg' }));
});

=> the first code works, but the second adds the image many times (seven times exactly) then throws a JavaScript Exception:

  • under Chrome: “Cannot read property 'cycleW' of undefined“
  • under Firefox 10: “next is undefined“

…

I’m a JavaScript beginner and I thought those two codes would do the same…

…
any idea?

  • 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-28T20:29:45+00:00Added an answer on May 28, 2026 at 8:29 pm

    Your second code has an error.

    It should be:

    $('<img>', ...);
    

    To create a new element the tag needs angle brackets around it!

    As written, it’s selecting every existing image tag on the page, and appending them to every instance of .produit.

    Ideally you should also use the map version of $('<tag>'), rather than calling .attr afterwards:

    $('<img>', {src: 'img.png', alt:'altimg'}).appendTo('.produit');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During development, I use this to load the latest jQuery: <script src=http://www.google.com/jsapi></script> <script type=text/javascript>
I have some like that. <script src=http://code.jquery.com/jquery-latest.js></script> <table> <tr title=test id=ex1> <td><div class=move>Hello</div></td> <td>&nbsp;</td>
If we look at the latest jQuery source at http://code.jquery.com/jquery-latest.js we see the following:
I have a very simple bit of jQuery to retrieve my latest Tweet $.getJSON(http://twitter.com/statuses/user_timeline/username.json?count=1,
I'm having troubles with the following code: <link type=text/css href=http://jqueryui.com/latest/themes/base/jquery.ui.all.css rel=stylesheet /> <script type=text/javascript
Could someone please tell me why my code for the jquery autocomplete is not
It seems that jQuery.browser is deprecated in the latest jQuery. The doc recommends that
Hey, I've tried to update jQuery to its latest version on a system I'm
I am using a jquery cycle plugin and flexdropdown in one page... What happens
I know one of the benefits of linking jQuery from Google's CDN is that

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.