1, simple display text content:
HTML code:
<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "> <HTMLxmlns= "http://www.w3.org/1999/xhtml"> <Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <title>To achieve fixed width on both sides, the middle adaptive width-</title> <Scriptsrc= "Jquery-2.2.3.min.js"></Script> <Scriptsrc= "Style.js"type= "Text/javascript"></Script></Head> <Body> <Divclass= "a">Move the mouse over a</Div> <Divclass= "B"style= "Display:none;">A shows up.</Div> </Body> </HTML>
View Code
JS Code:
varIshover =false; $(function() { $(". a"). Hover (function() {Ishover=true; $(". B"). Show (); }, function() {Ishover=false; SetTimeout (function() { if(!ishover) { $(". B"). FadeOut (); } }, 10); }); $(". B"). Hover (function() {Ishover=true; }, function() {Ishover=false; $(". B"). FadeOut (); });});View Code
2, with picture change
:
HTML code:
<Divclass= "Buy_car fl"> <imgsrc= "Images/shopcar.png"class= "Buy_car_img fr"/> <Divclass= "Buy_car_spec"> <P></P> </Div></Div>
View Code
JS Code:
$(function() { //Shopping cart Toggle Picture varIshover =false varTimer1 =NULL; $(". Buy_car_img"). Hover (function() {Ishover=true; $(". Buy_car_img"). attr ("src", "images/shopcarhover.png"); $(". Buy_car_spec"). Animate ({height:100 }, 200,function() { $(". Buy_car p"). HTML ("There is no product in the shopping cart, buy it quickly!") "); }); }, function() {Ishover=false; $( This). Stop (timer1); Timer1= SetTimeout (function() { if(!ishover) { $(". Buy_car_spec"). Animate ({height:0 }, 200,function() { $(". Buy_car p"). HTML (""); }); $(". Buy_car_img"). attr ("src", "images/shopcar.png"); } }, 200); }); $(". Buy_car_spec"). Hover (function() {Ishover=true; $(". Buy_car_img"). attr ("src", "images/shopcarhover.png"); $(". Buy_car_spec"). Animate ({height:100 }, 200,function() { $(". Buy_car p"). HTML ("There is no product in the shopping cart, buy it quickly!") "); }); }, function() {Ishover=false; $( This). Stop (timer1); Timer1= SetTimeout (function() { if(!ishover) { $(". Buy_car_spec"). Animate ({height:0 }, 200,function() { $(". Buy_car p"). HTML (""); }); $(". Buy_car_img"). attr ("src", "images/shopcar.png"); } }, 200); });View Code
Move the mouse over the content display