Saturday 15 March 2014

jquery - Switching form tabs represented by - -


I have created some form tabs using the block-display list item. Again, I have next and previous buttons, $ ('# wiznext') and $ ('# wizprev') . Whenever the next click is done, the next list is selected in the tab list, and the appropriate items are completed.

HTML is something like this:

  & lt; Ul id = 'tab' & gt; & Lt; Li & gt; Tab 1 & lt; / Li & gt; & Lt; Li & gt; Tab 2 & lt; / Li & gt; ...   

jquery is like this:

  $ ('# wizprev'). Click (function () (switchTab ($ current.prev) ('li'). Attr ('id'))}}   

However, I want to put a condition, i.e. Do not change the tab if there is no list item. If the user is already on 1 tab, then killing previous should do nothing.

I am doing this: I tried this condition but it does not matter:

  if ($ current.prev ('li'). Length & Gt; 0) Switch tab ($ current.prev ('li'). Attr ('id'));   

What is the correct way to do this?

Count any type of variable, which clicks the user on the previous or next, increases or decreases is. Something like this:

  var tabCounter = 1; $ ('# Wizprev') Click (function () {if (tab quarters> 1) {tabCounter--; switchTab ($ current.prev ('li').} ('Id'))}} $ ('# wiznext'). Click (function () {if (tabCounter & lt; $ ('# current li'). Length) {tabCounter ++; switchTab ($ current.next ('li') attr ('id').);} });   

Keep track of such number of tab numbers, and the user does not do anything on the first tab already. Then check that it is not the last to go to the next tab

No comments:

Post a Comment