Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

jquery add something to a div

How do I add something to a div if a media query is a specific width?

Meaning I have a div: <div id="container">

and if the screen is less than 900 pixels wide I would like to add to the div: data-stellar-vertical-offset="500"  so now when the screen width is less than 900 pixels the div will be
<div id="container" data-stellar-vertical-offset="500">
OR
Should I set up multiple instances of the div and hide them and then only display through the CSS if the page is a specific width?
ASKER CERTIFIED SOLUTION
Avatar of Mikkel Sandberg
Mikkel Sandberg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You may also want to set the 'data-stellar...' string to a variable so it's less typing :)
@Julian, good call on making a function for that. I forgot that you'd want to check that on page load too.