jQuery簡易時間軸実装方法の例

8629 ワード

この例では,jQuery簡易時間軸の実現方法について述べた.皆さんの参考にしてください.具体的には以下の通りです. timeLine
{bigAction}
{bigInfo}

{smallTime}

{smallAction}
{smallInfo}
var index = 0; $(function(){ hqOrderNodeCreate();// }) // function hqOrderNodeCreate(){ var bigTitleData = { bigAction: ' ', bigInfo: '' }; createBigTitle(bigTitleData, index); } // function baseOrderNodeCreate(){ var bigTitleData = { bigAction: ' ', bigInfo: '' }; createBigTitle(bigTitleData, index); } // function stockNodeCreate(){ var bigTitleData = { bigAction: ' ', bigInfo: '' }; createBigTitle(bigTitleData, index); } // function delNodeCreate(){ var bigTitleData = { bigAction: ' ', bigInfo: '' }; createBigTitle(bigTitleData, index); } // function setNodeCreate(){ var bigTitleData = { bigAction: ' ', bigInfo: '' }; createBigTitle(bigTitleData, index); } // , function createBigTitle(bigTitleData, index){ // $('.timeLine').append($('#bigTitleTpl').html() .replace('{bigAction}', bigTitleData.bigAction) .replace('{bigInfo}', bigTitleData.bigInfo) ); // var bigContentData = [{ smallTime: '2010.10.11', smallAction: ' ' + index, smallInfo: ' : 10:30:55' },{ smallTime: '2010.10.15', smallAction: ' ' + index, smallInfo: ' : 10:10:55' },{ smallTime: '2010.10.15', smallAction: ' ' + index, smallInfo: ' : 10:10:55' }]; var bigContentTplStr = $('#bigContentTpl').html(); var str = ''; for(var i=0; i< bigContentData.length; i++){ str += bigContentTplStr.replace('{smallTime}', bigContentData[i].smallTime) .replace('{smallAction}', bigContentData[i].smallAction) .replace('{smallInfo}', bigContentData[i].smallInfo); } $('.bigContent:eq(' + index + ')').html(str).hide().slideDown(500); } // , $('.showMore').on('click', function(){ if($(this).text() === ' '){ if(index === 0){ index++; baseOrderNodeCreate();// } else if(index === 1){ index++; stockNodeCreate();// } else if(index === 2){ index++; delNodeCreate();// } else if(index === 3){ index++; setNodeCreate();// $(this).text(' →_→ '); } } }) // + - $(document).on('click', '.bigButtonSeeMore', function(){ var clickObj = $(this); var bigContentObj = clickObj.parent().next().next(); if(clickObj.text() === '+'){ bigContentObj.slideDown(500, function(){ clickObj.html('<a href="javascript:;" rel="external nofollow" rel="external nofollow" ">-</a>');// }); } else if(clickObj.text() === '-'){ bigContentObj.slideUp(500, function(){ clickObj.html('<a href="javascript:;" rel="external nofollow" rel="external nofollow" ">+</a>'); }); } })

jQueryの関連内容についてもっと興味のある読者は、「jQuery拡張テクニックまとめ」、「jQuery常用プラグインと使い方まとめ」、「jQueryドラッグ特効とテクニックまとめ」、「jQuery表(table)操作テクニックまとめ」、「jqueryにおけるAjax使い方まとめ」、「jQueryによく見られる経典特効まとめ」、『jQueryアニメーションと特効用法まとめ』および『jqueryセレクタ用法まとめ』
本文で述べたことが皆さんのjQueryプログラム設計に役立つことを望んでいます.