Jump to content

return false problem


robert_gsfame

Recommended Posts

i have a tab menu let say tab1,tab2 and tab3

 

and i have this <a href="#tab1">tab1</a> to open the first tab

 

there is no problem actually with the tab itself only i always get back to the top of the page after the chosen page open, can i avoid this like when using javascript:void(0)

 

 

 

Link to comment
Share on other sites

use html anchor tags,

http://www.hypergurl.com/anchors.html#bottom

 

i.e.

<html>
<body>
<a href='#tab1'>Tab1 Content</a>
<br />
<br />
<br />
<br />
<br />
<br />
<br /><br />
<br /><br /><br /><br /><br />
<br />
<br />
<br />
<br />
<br />
<br /><br />
<br /><br /><br /><br />
<a name='tab1'>Tab1 Content:</a><br />
Rarrarararar etc etc etc.
</body>
</html>

Link to comment
Share on other sites

You don't want the link to go anywhere?

 

You can have something like <a href='#'>Link</a>

 

or, if you want the link to go to a certain point on a new page - say home.html

then have the anchor tag on the page somewhere so the link would be home.html#anchor

and the html


home.html
<html>
<body>
<br />
<br />
<br /><br />
<br /><br />
<br />
<br />
<br />
<br />
<br />
<br /><br />
<br /><br /><br /><br />
<a name='anchor'>Content Here:</a><br />
Rarrarararar etc etc etc.
</body>
</html>

 

If this isn't right, I don't understand what you're after. What are you after?

Link to comment
Share on other sites

How are you opening the tabs? Are you using the onclick event handler in the link? If so, then just use void:

 

<a href="javascript: void(0);" onclick="javascript: changeTab('home');">Home</a>

 

It's hard to say without seeing more of your code or knowing how your achieving the tabs.

Link to comment
Share on other sites

<script type="text/javascript">

 

$(document).ready(function() {

 

//Default Action

$(".tab_content").hide(); //Hide all content

$("ul.tabs li:first").addClass("active").show(); //Activate first tab

$(".tab_content:first").show(); //Show first tab content

 

//On Click Event

$("ul.tabs li").click(function() {

$("ul.tabs li").removeClass("active"); //Remove any "active" class

$(this).addClass("active"); //Add "active" class to selected tab

$(".tab_content").hide(); //Hide all tab content

var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content

$(activeTab).fadeIn(); //Fade in the active content

return false;

});

 

});

</script>

 

 

n i have this html code

 

<ul class="tabs">

<li><a href="#tab1">Tab1</a></li>

<li><a href="#tab2">Tab2</a></li>

</ul>

 

<div id="tab1" class="tab_content">blablabla</div>

<div id="tab2" class="tab_content">blablabla</div>

Link to comment
Share on other sites

In that case. You're returning false on the list, which won't do anything. You'll need to do some re-arranging. Try this:

 

$("ul.tabs li a").click(function() {
$("ul.tabs li").parent().removeClass("active"); //Remove any "active" class

$(this).parent().addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content

var activeTab = $(this).attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
return false;
});

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.