1 / 10

More jQuery

More jQuery. Professor Josh Miller Lehigh university | fall 2010. Writing your own…. As always, you must link to the jquery javascript file- or link to the live version online <script src =" http://code.jquery.com/jquery-latest.min.js "></script >

art
Download Presentation

More jQuery

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. More jQuery Professor Josh Miller Lehigh university | fall 2010

  2. Writing your own… • As always, you must link to the jqueryjavascript file- or link to the live version online <script src="http://code.jquery.com/jquery-latest.min.js"></script> • Your code can go in the head section or in an external js file (linked the same was as above) <head> <script type="text/javascript"> $(document).ready(function() { //  your code goes here… by the way // means a comment- a note to yourself }); </script> </head>

  3. Code linked to document.ready… <script type="text/javascript"> $(document).ready(function() { alert("hello"); }); </script>

  4. Redefine a click action… <script type="text/javascript"> $(document).ready(function() { $('a#hideDiv').click(function() { $('#redDiv').hide(1000); return false; }); }); </script> Line 4: redefines the click action for links (a) with the id (#) of hideDiv Line 5 : hides the visibility of the div with the id (#) redDiv, animation takes 1000 ms to complete 1 2 3 4 5 6

  5. Redefine a click action… <script type="text/javascript"> $(document).ready(function() { $('a#hideDiv').click(function() { $('#redDiv').toggle(1000); return false; }); }); </script> Line 4: redefines the click action for links (a) with the id (#) of hideDiv Line 5 : toggles the visibility of the div with the id (#) redDiv 1 2 3 4 5 6

  6. Redefine a click action… $('#clickme').click(function() { $('#puppy').hide(1000); return false; }); … <div id="clickme"> Click here </div> <img id=”puppy" src=”adorablepuppy.jpg” />

  7. Mootools accordion • (easier to implement than jquery solutions, but doesn’t play nicely with jquery libraries) • http://demos.mootools.net/Accordion • Link to the js & css, modify code in both to customize • Implementation: <div id="accordion"> <h3 class="toggler">title</h3>  title of menu option <div class="element"> …  content inside slider here </div> </div>

  8. Mootoolsfx.slide • http://demos.mootools.net/Fx.Slide • Link to js & css- must modify js to use subset of functionality • For example to use only toggle, your js file only needs to include window.addEvent('domready', function() { varmyVerticalSlide = new Fx.Slide('vertical_slide'); $('v_toggle').addEvent('click', function(e){ e.stop(); myVerticalSlide.toggle(); }); });

  9. AnythingSlider • http://css-tricks.com/anythingslider-jquery-plugin/ • Btw, are you reading css tricks every day? You should. And smashing magazine. • Link to the js & css • Implementation: <div class="anythingSlider"> <div class="wrapper"> <ul> <li> …  content of slide </li> <li> …  content of slide </li> </ul> </div> </div>

  10. What now? • Well, I’m not going to teach you anymore jQuery… • You should be able to apply the gallery & content slider examples to any library you need to implement • Here’s an incredibly useful resource • http://jqueryfordesigners.com/

More Related