I've tried over and over to change this function to jQuery but I can't seem to get it to run properly. Could anyone give me any help with it at all?
window.onresize = resizeImage;
function resizeImage(){
var newHeight = document.documentElement.clientHeight;
var newWidth = document.documentElement.clientWidth;
document.getElementById('crofthouse').width = (newHeight / 2) * 1.33;
document.getElementById('crofthouse').height = (newHeight / 2);
document.getElementById('main').style.width = (newHeight / 2) * 1.33;
document.getElementById('main').style.height = (newHeight / 2);
var margin = (newHeight - document.getElementById('crofthouse').height) / 2;
document.getElementById('main').style.margin = margin + ',auto,' + margin + ',auto';
}
here's my attempt at converting it window.onresize = resizeImage;
function resizeImage(){
var newHeight = document.documentElement.clientHeight;
var newWidth = document.documentElement.clientWidth;
$("#crofthouse").css("width, (newHeight /2) * 1.33")
$("#crofthouse").css("hegiht, (newHeight /2)")
$("#main").css("width, (newHeight /2) * 1.33")
$("#main").css("height, (newHeight /2)")
var margin = (newHeight - $('#crofthouse').css("height) / 2");
$('main').css("margin = margin + ',auto,' + margin + ',auto'");
}
document.getElementById('crofthouse').width = ...should go to$("#crofthouse").css("width", (newHeight /2) * 1.33). Note the quote placement. Also, consider using the mutli-CSS selector or chaining or using a variable to avoid re-created a jQuery (re-evaulating a selector) each time.var house = $(#"crofthouse"); ... house.css(...). That will also help reduce errors like$("main")