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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:38:23+00:00 2026-05-19T14:38:23+00:00

im working with jquery. I appended an image into my div-element. it works great.

  • 0

im working with jquery. I appended an image into my div-element. it works great.
i want to change a css property (like max-heigth or width etc.) with a js-function.

but nothing works… i tried it with an image fix on the page (withouth appending before, strict in the html..) and that works…

does anybody has an idea??

my function looks like this:

function makeBigger() {

 var origHeight = $("#articlePicture").css("max-height");
 var newHeight = parseInt(origHeight.replace("px", ""));

 newHeight+=25;
 newHeight+="px";

 $("#articlePicture").css("max-height", newHeight);
}

thanks!

edit: important to say: it doesn’t work only with the appendet picture, firebug etc. everything tried – works!

edit2: appending-function (kind of an easy version of it..):

function appendThis(artikelNumber, pictureToAppend) {
        img="<img src='"+pictureToAppend+"' alt='articlePicture' id='articlePicture' class='articlePicture' />";
        $('.article'+artikelNumber+'Text').append(img);
    }
  • 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-19T14:38:24+00:00Added an answer on May 19, 2026 at 2:38 pm

    There are two things in your appendThis function that could be the reason for it not working.

    1. Every time you run this function (and append a new image), you assign the same ID to that image. That is not good, ID’s have to be unique on the page. If you have multiple elements with the same ID, jQuery won’t be able to select them. You should use the class attribute instead. That way, you can select the images like so: $('img.articlePicture')

    2. You didn’t declare the variable img, thus making it an implicit global. This should be avoided, since it can lead to unexpected name-collisions.

    I fixed both issues below:

    function appendThis(n, url) {
        var img = '<img src="' + url + '" class="articlePicture" alt="Picture">';
        $('.article' + n + 'Text').append(img);
    }
    

    Also, here is an optimized version of your makeBigger function:

    function makeBigger() {   
        $("img.articlePicture").css('max-height', function(i,v) {
            return parseInt(v, 10) + 25 + 'px';
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working jQuery, what I'd like to perform is something similar to the following: $('sometag').children().wrap('<div></div>');
I'm using CSS's resize property to resize a div element in FF, Safari, and
I am working on jquery slider to take min and max price and I
I am trying to detect an event in a jQuery appended element. How do
I have a working jquery image carousel that I was building. It's mostly finished
I'm working with JQuery and jsTree, and I've run into some confusion about how
Still working through JQuery to get data and repopulate portions of a page. Right
I'm currently working with jQuery 1.4.2 and jQuery UI 1.8.2. I'm experiencing some weird
I'm working with jquery. And i have text input in a form, i would
I'm working with Jquery in Drupal. I have sets of four blocks that all

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.