Robert Granlund
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-offs et="500" so now when the screen width is less than 900 pixels the div will be
<div id="container" data-stellar-vertical-offs et="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?
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-offs
<div id="container" data-stellar-vertical-offs
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.