Quantcast
Channel: jQuery Image Resize not working - Stack Overflow
Viewing all articles
Browse latest Browse all 2

jQuery Image Resize not working

$
0
0

I am new here, I'm having a problem in my website recently, see, I made it so it would always be 10% of the image uploaded with jQuery, this is my HTML:

<body><!--Before this of course I had the DOCTYPE html--><div id="topbarUI" style="text-align: center; font-size: 25px;"><div id="profile" style="display: inline-block; margin: 0px; margin-right: 10px; float: left;"><a href="DCV_Diego"><img style="border-radius: 15px;" id="profilepicfortopbar" src="Logo.png" alt="DCV's profile pic"></a></div></div><script src="jquery-2.1.0.min.js"></script><script src="script.js"></script></body>

The image I want to change is the one that has the ID tag of profilefortopbar.
Here I have my jQuery(in my script.js file):

$("#profilepicfortopbar").each(function(){    $(this).width($(this).width() * 0.1);});

As you can see, it gets the current width of the image and makes it the same thing, but times 0.10, which is 10%.

It use to work for everything, but for some reason now it doesn't work, it keeps the same size of the original picture without multiplying by by 0.1.
UPDATEThe problem for some reason, was that I linked the js files on the bottom of the page, not on the top. This solved my problem! Thanks to u all anyways :D


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images