The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Javascript statement to run depending on window size
belowHeights00
post Mar 18 2014, 09:01 AM
Post #1


Member
***

Group: Members
Posts: 67
Joined: 4-February 14
Member No.: 20,319



So I've been learning javascript/jquery lately and was trying to run a certain script(s) depending on window size. The way I've written it is as follows:

$(window).load(function() {
$('#promo').fadeIn(2000);
if ($(window).width() >= 800) {
$('#promo').mouseenter(function() {
$('#promo').css({'height':'240px', 'background-color':'#fff', 'color':'#000', 'opacity':'1', 'border':'solid 1px #000'});
$('#promo p').css('text-decoration', 'underline');
$('#promo').mouseleave(function() {
$('#promo').css({'height':'45px', 'background-color':'#000', 'color':'#fff', 'transition':'1.5s', 'border': 'none'});
$('#promo p').css('text-decoration', 'none');
});
});
};
});

Reason being is hover doesn't work well on mobile devices...also I would like the fadein function to still work on smaller screens. I have worked around this by adding display: none; to it's css page using @media but I'd rather the former. Any help is appreciated thank you
~Casey Stack huh.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post Mar 18 2014, 11:21 AM
Post #2


Programming Fanatic
********

Group: Members
Posts: 5,146
Joined: 23-August 06
From: Europe
Member No.: 9



I'm not very well into jQuery, but I suggest you look into jQuery mobile at http://jquerymobile.com .
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
belowHeights00
post Mar 19 2014, 06:39 AM
Post #3


Member
***

Group: Members
Posts: 67
Joined: 4-February 14
Member No.: 20,319



I have never seen that before but it looks/sounds awesome! I assume I would put all those files (I d/l'ded the big zip file with all the css and some js files) into my site folder as well as link 'em - but if I do this, would I not have to put links onto every html page? Maybe I am misunderstanding the practicality of those scripts...can you elaborate a tiny bit Frederiek please?
Thank you
-Casey
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post Mar 20 2014, 03:11 AM
Post #4


Programming Fanatic
********

Group: Members
Posts: 5,146
Joined: 23-August 06
From: Europe
Member No.: 9



I have no idea, I hardly ever use jQuery at all. I'd have to read about jQuery mobile just as much as you.
- http://api.jquerymobile.com
- http://demos.jquerymobile.com/1.4.2/

BTW, you might also look into hammer.js, a javascript library for multi-touch gestures. There's a jQuery plugin available too.
See http://eightmedia.github.io/hammer.js/ .
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 09:10 AM