I have a website:
link
There are two pages on my site that have the same div elements... I want one page to perform a certain calculation on the divs, and another page to perform a different calculation...
New JavaScript Code:
jQuery(document).ready(function ($) {
var windowsizecontact = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
console.log("screen contact:",windowsizecontact);
var stanga= jQuery('.contact-stanga').outerWidth();
console.log("left side:",stanga);
var dreapta= jQuery('.contact-dreapta').outerWidth();
console.log("right side:",dreapta);
var contentcontactwh=windowsizecontact-stanga-dreapta;
console.log("result",contentcontactwh);
$('.contact-container #primary').css{('cssText', contentcontactwh'!important')}; //here I want to override this div
});
This is the old code (which should only apply to specific pages)
jQuery(document).ready(function ($) {
var width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var leftSide = jQuery('#secondary').outerWidth();
var selected = jQuery('.selected').outerWidth();
var calculation = width - leftSide - selected;
$('#primary').css('width', calculation);
});
My issue is that the new code above does not affect the div on the contact page because of the old code... and I need it to be unique. (The old code must still exist)
Is there a way to override this somehow?
EDIT:
jQuery(document).ready(function ($) {
var windowsizecontact = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
console.log("screen contact:",windowsizecontact);
var stanga= jQuery('.contact-stanga').outerWidth();
console.log("left side:",stanga);
var dreapta= jQuery('.contact-dreapta').outerWidth();
console.log("right side:",dreapta);
var contentcontactwh=windowsizecontact-stanga-dreapta;
console.log("result",contentcontactwh);
console.log("------------------");
if ($("#primary").hasClass("content-contact")) {
alert("ggg");
$('.content-contact').css("width:",contentcontactwh); //the issue lies here now
}else
{
var width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var leftSide = jQuery('#secondary').outerWidth();
console.log("left side:",leftSide);
var selected = jQuery('.selected').outerWidth();
console.log("left side:",leftSide);
var calculation = width - leftSide - selected;
$('#primary').css('width', calculation);
}
});
I tried the first suggestion given... but now the div width is not being applied correctly.
Did I make a mistake in the syntax?