Hey! Do you have any query related to front end?

Sign in Sign up

Tabbing with id and rel attributeBack

How it works

It is quiet simple. This grabs the id of the tab LI and the rel attribute of details LI and match it for equality. As it match with each other, it hides all details data and show the matched details accordingly. The concept is this only.

Whole code is here:

	$('.tabs li').click(function(){

		//Remove activeTab class from all li of tabs
		$('.tabs li').removeClass('activeTab');

		//Add activeTab class on clicked li of tabs

		//Grab ID attribute of clicked id
		var targetRel = $(this).attr('id');

		//Remove activeTabDetail class from all li of details
		$('.tabDetailsCon li').removeClass('activeTabDetail');

		//Run loop for tab details container
		$('.tabDetailsCon li').each(function(){

			//Grab rel attribute of each detail container
			var relval = $(this).attr('rel');

			//Equate id and rel variable
			if(targetRel == relval){

				//Add activeTabDetail class to equated detail

				//Break the loop as it got the result from extra looping
				return false;

What's the use if index() function is there:

This is good idea to tab any content on the page. Because it works related to id and rel rather then position on the page.

How to comment:

  • Create an account in discuss by clicking on login next to arrow.
  • Create password for discuss and varify your email id, through your mail.
  • Refresh page and comment.

You might also like

  • Characters limit in textarea

    Limit charecters in textarea without extra space.

    • 298
    • 5
    • 298
    • facebook icon
    • twitter icon
    • google plus
  • Tabbing with id and rel attribute

    Tabbing functionality with respect to ID and rel attribute.

    • 286
    • 8
    • 286
    • facebook icon
    • twitter icon
    • google plus
  • Css before and after

    CSS before and after

    • 260
    • 2
    • 260
    • facebook icon
    • twitter icon
    • google plus

Latest quries posted

gopa kumarabout 4 years ago

amit singhabout 4 years ago

rahmat aliabout 4 years ago

mandavi tiwariabout 4 years ago

rahul sharmaabout 4 years ago

Ask question
Latest video
Learn Angular
Profile pic
Guest Back