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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:09:50+00:00 2026-05-20T10:09:50+00:00

HTML: <div> <img src=image.png /> </div> JS: $(div img).animate({opacity:.5}, 200); This js works good

  • 0

HTML:

<div>
<img src="image.png" />
</div>

JS:

$("div img").animate({opacity:.5}, 200);

This js works good once page is loaded. But doesn’t handle content loaded by ajax. Given js code is just an example.

The question is, how to make some js code work for ajaxified content?


Have tryed this way:

function loadDone(){
    $("div img").animate({opacity:.5}, 200);
};

loadDone();

$.ajax({
    url: "test.html",
    success: function(){
        //do something
        loadDone();
    }
});

But it doesn’t work.

I know how to add triggers, the problem is, this code doesn’t use any. It just works once the page loaded and then stops. Should work also for ajaxified content.

  • 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-20T10:09:50+00:00Added an answer on May 20, 2026 at 10:09 am

    Your question is a little vague, but this might help.

    Assuming you run this code on document ready:

    $(function() { 
      if ($("div img").width() > $("div").width()){
        $("div img").css({"width": $("div").width()});
      }
    });
    

    You could repeat this call in a ajax callback:

    $("#some_div").load("/html_fragment_with_cool_image", function() { 
      if ($("div img").width() > $("div").width()){
        $("div img").css({"width": $("div").width()});
      }
    });
    

    Or, go a step further and wrap it in a function.

    function doDivStuff() {
      if ($("div img").width() > $("div").width()){
        $("div img").css({"width": $("div").width()});
      }
    }
    

    And then call it when you need to.

    $(function() { 
      doDivStuff();
    });
    
    $("#some_div").load("/html_fragment_with_cool_image", function() { 
      doDivStuff();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this html: <div class=nation> <a href=library.php?type=nation&amp;id=America> <div class=nation-image> <img src=nations/America.png alt=snip /> </div>
---HTML <div id=story> <div id=individual> <img src='uploads/1231924837Picture.png'/> <h2>2009-01-14</h2> <h1>Headline</h1> <p>stroy story etc stroy story
I have the following HTML <div id=testID class=test1> <img id=testID2 class=test2 alt= src=some-image.gif />
Here is my HTML: <li> <div class=menu_inner> <a href=#> <div class=button><img class=486 src=images/portalbutton.png /></div>
I have multiple div's that look like this: <div><a href=our_work.html?clientid=39> <img src=filestore/data_logos/39.gif alt=client logo/>
I have the below xpath expression //div[@class=post-content]//img which runs on a html page, scanning
My HTML: <div id=gallery-thumbs> <div class=thumb> <img alt=2 src=gallery/thumbs/2.jpg class=thumbimg hand /> </div> <div
I have the following HTML <div> <img id=image1 src=http://valleywag.com/assets/resources/2008/03/BlackGoogleLogo.jpg alt=Why doesn't this float correcly?
given the html: <div class=ships> <div class=ship header> </div> <div class=ship> <div class=image> <img
I have the following HTML: Current HTML <div id=testContainer> <a href=testPage.htm target=_top> <img src=/res/images/testImage_M.jpg?lc=en-GB&lv=5.jpg

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.