Hi, I'm pretty new to jQuery as a whole and really have appreciated the help and feedback of these forums. I just was hoping someone could tell me if this is the best way to do this. I finally got this thing working (haven't added all the sweet stuff to it).
through my research it seems there are a ton of different ways to get jQuery to do what you want. Was this the best way to execute this? Should I have done it differently?
I just want to make sure I'm doing it right rather than "just making it work".
<p style=\"text-align: center;\">For questions of any kind, please call us Monday - Friday 8am to 5pm. Otherwise email us and we will contact you in 2 shakes of a lambs tail.</p> <p style=\"font-family: georgia; color: rgb(119, 119, 119); font-weight: bold; font-size: 30px; text-align: center;\">520-205-2306</p>
<p>For questions of any kind, please call us Monday - Friday 8am to 5pm. Otherwise email us and we will contact you in 2 shakes of a lambs tail.</p> <p id=\"contactNumber\">520-205-2306</p>
Its bad practice and clean code is just better for the eyes ;)
2nd thing
In css its encouraged to use as many elements to select one (I.E. == html body div.content div#nav li.action {....) When using jquery, its just the opposite
jQuery(\"li.action\").click(function(){....
What this is doing is selecting every single <li> on the page.... stores them and then filters all those <li> looking for the class name "action"
note: Selecting by a class is slower than id
3rd thing
<li class=\"action\">Contact Us</li>
This is the only element with the class of "action", Classes generally apply to multiple elements and this is the clearly the only li that is going to have the action therefor should be an id
The Element is also supposed to be click able and you dont get the pointer when hovering fixable by css (cursor: pointer;) or better yet
<a href=\"#\" id=\"action\">Contact Us</a>
It is supposed to be a clickable element its always good to not reinvent the browser recreating the way it defaultly acts
4th Thing
Notice the little jump at the end of the slide down and beginning of the slide up?
It seems like you could remove a handful of elements that dont need to be there (ie div id='lower') that just has the height of 5px... you can just apply top margin to the header element
http://www.citrusbunny.com/
*It's the "Contact Us" on the right side - supposed to slide out*
through my research it seems there are a ton of different ways to get jQuery to do what you want. Was this the best way to execute this? Should I have done it differently?
I just want to make sure I'm doing it right rather than "just making it work".
This is the code for the slide:
stylesheet.css
indexcustom.php
Header.php
Its bad practice and clean code is just better for the eyes ;)
2nd thing
In css its encouraged to use as many elements to select one (I.E. == html body div.content div#nav li.action {....)
When using jquery, its just the opposite
jQuery(\"li.action\").click(function(){....What this is doing is selecting every single <li> on the page.... stores them and then filters all those <li> looking for the class name "action"
note: Selecting by a class is slower than id
3rd thing
This is the only element with the class of "action", Classes generally apply to multiple elements and this is the clearly the only li that is going to have the action therefor should be an id
The Element is also supposed to be click able and you dont get the pointer when hovering fixable by css (cursor: pointer;) or better yet
It is supposed to be a clickable element its always good to not reinvent the browser recreating the way it defaultly acts
4th Thing
Notice the little jump at the end of the slide down and beginning of the slide up?
remove the height, it will fix that
5th thing....
It seems like you could remove a handful of elements that dont need to be there (ie div id='lower') that just has the height of 5px... you can just apply top margin to the header element
And im tired....