IMG has 0x0 pixels when src added with jQuery

Riiwo

I was making custom modal popup(#light1). In my JavaScript I take src from the image I clicked on and add it to img tag with id addable.

jQuery

var images=$('#raam img'), index=0
$(images).click(function() {
    var src= $(images.eq(index)).attr('src');
    $("#addable").attr('src', src)
    $('#light1').css("display","block")
});

And HTML

<div id="raam">                
    <img id="pilt1" src="uudistepildid/1.jpg" alt="1">
    <div id="light1" class="wcontent">
        <img id="addable">
    </div>
</div>

and CSS

#addable { 
    width: 600px;
    height: 600px; //even forcing doesn't help
}

This all works fine. When I inspect it shows me the right src and sytle with width and height, but it has size 0x0 and I can't change it. It even tells me its natural size. I leave snapshot with the problem.

This is what inspector shows:

http://i.stack.imgur.com/zlSdR.png

This is what it looks like( I took out some unnessesay code, just to make it faster to read);

http://i.stack.imgur.com/5iDb6.png

VVV

Your image uses the styles you applied to #raam img which sets the image to visibility:hidden. When you do display:block to show it, it's there physically (I mean you can access it's properties but it's not visible). In order to have it show on screen, you need to set it's visibility to visible.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

IMG has 0x0 pixels when src added with jQuery

From Dev

jquery check if img has src

From Dev

Change img src when clicked jquery

From Dev

cycle img src from array jQuery when div is clicked

From Dev

remove part of jQuery base uri when changing src of an img tag

From Dev

What happens when you change the src of an img tag with jquery?

From Dev

How to change img src added by on click function?

From Dev

jQuery, if window has scrolled X pixels do this, else if has scrolled XX pixels do something else

From Dev

With jquery want to ad to html id &#x2191; or img src

From Dev

With jquery want to ad to html id &#x2191; or img src

From Dev

jQuery img src replace not working

From Dev

Amend img src using jQuery

From Dev

Replace img src with js jquery

From Dev

How to move img src a few pixels down in html page

From Dev

Detect when <img> src is updated

From Dev

Replace img src for td img if has a class specific word

From Dev

jQuery - img src change on hover and on click

From Dev

How to set img src to php session in jquery

From Dev

jQuery how to change img src path onclick?

From Dev

jQuery get img src within a href on click

From Dev

jQuery use td value as src for img

From Dev

Jquery attr src does not include img tag

From Dev

How to obtain absolute img src url with Jquery

From Dev

Jquery/Javascript changing img SRC with IF/ELSE statement

From Dev

jQuery - variable inside img src returns undefined

From Dev

Change background JQuery depending on img src

From Dev

How to get img src inside a href jquery

From Dev

jquery img src replace doesn't work

From Dev

jQuery - img src change on hover and on click

Related Related

HotTag

Archive