I'm having issues with figuring out the correct syntax to have my code check the value of one of my images with the id '#main'. My CSS has the image changing its src based on a media query using the content:url attribute. The reason I'm doing it this way is because I have about 5 different background images that trigger at different widths to provide a frame for my content and I need to be able to adjust the height of my ".text" div based on what image is being used as the frame currently.
I understand how to code all that, all I need is help with how to ask for the value correctly on the first one and I should be able to do the rest from there. Just to clarify once again, the issue is in the if/else statement; the code works without the if/else statement.
Here is what I have:
function updateHeight()
{
if ($("#main").css('content') === 'url("../images/main-bg2-landscape.png")') {
var div = $('.text');
var width = div.width();
div.css('height', width *.57);}
}
Just an example of the CSS in place:
#main {z-index: -1;
position: absolute;}
.text {position: absolute;
background-color: #FFFFFF;
background-position: top;
left: 11%;
width: 78%;
margin-top: 19%;
opacity: .4;}
@media only screen and (min-width: 1025px) {
#main {content:url(../images/main-bg2-landscape.png);}
.text {position: absolute;
background-color: #FFFFFF;
background-position: top;
left: 11%;
width: 78%;
margin-top: 19%;
opacity: .4;}
}
Thanks