ACAD275:
Dev 1a Spring 2023 March 07, 2023 |
Resource -- Demo: jQuery sliding panels: jQuery lecture demo using animation and attr |
Save to your computer jq_classes_1a.html
jQuery demo -- code up a sliding panels page:Please note: This demo is meant to be done AFTER having gone through the second jQuery lecture "jQuery Part 2". First off, load up the start file jq_classes_1a.html. Now perform the following steps inside the document ready jQuery script area provided:
Wnen you are done your page should be performing like jq_classes_1b.html Then for a bit more advanced functionality, which will require a tiny bit of manual javascript. Take a look at the item objects (the divs we use as triggers). NOtice that they have href attributes... even through they are not "links". I have saved URL info as "href" attributes of the divs. Now we will add to the jQuery bind block such that we copy that href value to a variable, and then use that to set the src of hidden iframes to that web site to give a "preview" of the site: $(".item").bind("mouseover", function() { $(this).css("background-color","yellow") ; $(this).next(".info").slideDown(2000); // more advanced functionality -- expands the iframe at the bottom and sets the src // (web page) of the iframe to an href that was stored in a div... $("#ifra").attr("height","600"); $("#ifra").attr("src", $(this).attr("href") ); }); You can see that final step in action at jq_classes_2b.html. |