I need help figuring out how to create a variable in my script that is defined by the width attribute of a CSS class. The snippet I have currently doesn't seem to work as expected.
var dist = $('.nav').css(width());
The goal of my script is to slide the .nav class when clicked. The issue arises because I'm using @media queries to adjust the width of .nav, which is the exact value I need for the sliding functionality. My approach here is to set the variable "dist" based on the width attribute of .nav - this way, I can simply use "dist" as the slide distance in the function.
I feel like what I'm attempting should be straightforward, yet I might be way off track. Is there a simpler method I should consider instead?