基于jquery的代碼顯示區(qū)域自動拉長效果
更新時間:2011年12月07日 23:49:35 作者:
今天看到一個技術(shù)類網(wǎng)站,在顯示代碼的地方,邊框會拉長,很方便用戶閱讀體驗,特看了下代碼,原理很簡單,使用了jquery,不適用也可以實現(xiàn)
下面是jquery的實現(xiàn)代碼:
$(document).ready(function(){
$('pre').hover(
function(){
if($(this).width()==520){
$(this).animate({width:'800'},400);
$(this).css({border:'1px solid #2B99E6'});
}
},
function(){
if($(this).width()==800){
$(this).animate({width:'520'},400);
$(this).css({border:'1px solid #555555'});
}
}
);
復(fù)制代碼 代碼如下:
$(document).ready(function(){
$('pre').hover(
function(){
if($(this).width()==520){
$(this).animate({width:'800'},400);
$(this).css({border:'1px solid #2B99E6'});
}
},
function(){
if($(this).width()==800){
$(this).animate({width:'520'},400);
$(this).css({border:'1px solid #555555'});
}
}
);
相關(guān)文章
jquery綁定事件 bind和on的用法與區(qū)別分析
這篇文章主要介紹了jquery綁定事件 bind和on的用法與區(qū)別,結(jié)合實例形式分析了jquery綁定事件 bind和on的基本功能、用法、區(qū)別與操作注意事項,需要的朋友可以參考下2020-05-05jQuery中綁定事件bind() on() live() one()的異同
本文主要介紹了jQuery中綁定事件bind() on() live() one()的異同,具有很好的參考價值,下面跟著小編一起來看下吧2017-02-02