Reputation: 686
I'm creating a website and I have a problem with IE compatibility. My idea to fix this is to have a JQuery script that changes the images width proportional to the window. However, my script isn't working.
$(document).read(function() {
updateSizes();
$(window).resize(function() {
updateSizes();
})
});
function updateSizes() {
var $windowHeight = $(window).height();
var $windowWidth = $(window).width();
$(".fadingImg").css("width",$windowWidth * 0.7)
}
I have tried adding + "px"
to $(".fadingImg").css("width",$windowWidth * 0.7)
My JQuery implementation is:
<script src="http://abrahamyan.com/wp-content/uploads/2010/jsslideshow/js/jquery-1.4.3.js" type="text/javascript"></script>
Upvotes: 0
Views: 87
Reputation: 3636
if your fadingImg is a <img>
, then try to set the attribute
$(".fadingImg").attr("width",$windowWidth * 0.7)
Upvotes: 0
Reputation: 363
Instead of using JavaScript for this solution, why not use CSS?
.fadingImg { width: 70%; }
Upvotes: 0
Reputation: 21023
You need to add px but in the right place
$(".fadingImg").css("width", ($windowWidth * 0.7) + "px")
You also need to make sure that you have class="fadingImg"
You also need to make sure that you put it within a ready block
$(function() {
//code here
});
Upvotes: 0