form.js 892 B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * FORM表单选项卡
  3. */
  4. $(function() {
  5. var current = 1;
  6. var stepsWidth = 0;
  7. var widths = new Array();
  8. $('#steps .step').each(function(i){
  9. var jqstep = $(this);
  10. widths[i] = stepsWidth;
  11. stepsWidth += jqstep.width();
  12. var jqlink = $('#navigation li:nth-child(' + parseInt(i+1) + ') a');
  13. var valclass = 'checked';
  14. $('<span class="'+valclass+'"></span>').insertAfter(jqlink);
  15. });
  16. $('#steps').width(stepsWidth);
  17. $('#navigation').show();
  18. $('#navigation a').bind('click',function(e){
  19. var jqthis = $(this);
  20. var prev = current;
  21. jqthis.closest('ul').find('li').removeClass('selected');
  22. jqthis.parent().addClass('selected');
  23. current = jqthis.parent().index() + 1;
  24. $('#steps').stop().animate({
  25. marginLeft: '-' + widths[current-1] + 'px'
  26. },500,function(){
  27. });
  28. e.preventDefault();
  29. });
  30. });