JQuery :: FAQ Show / Hide Function - If Statement

Jun 24, 2010

I have a simple FAQ show/hide function set up however I am having trouble setting up an if clause. My code is:
$(document).ready(function(){
$("dd").hide();
$("dt").click(function(){
$("dd").hide('slow');
$(this).next().slideToggle();
});
});

However, when you click on the same item twice it firstly hides and then reshows it, I need an if statement that basically states;
if "this?!" is visible/shown
Then do nothing
else
$("dd").hide('slow');
$(this).next().slideToggle();
I am unsure of the syntax and can't figure out what property I can trace out to see if the item is being shown or not.

View 4 Replies


ADVERTISEMENT

JQuery :: For Statement To Show / Hide Fields

May 4, 2011

I'm trying to use jquery to hide some contents in a for statement but is not working. Here is the code

if( $total_attachments > 0 ) {
for ($i=0; $i < $total_attachments; $i++) {
//output div and image in it
echo '<div class="pictures_entry">';
echo '<a href="'.$attachments[$i]["location"].'" title="'.$attachments[$i]["title"].'" rel="prettyPhoto[gallery]"><img src="'.$attachments[$i]["location"].'" width="128" height="120" alt="'.get_the_title().'" /></a>';
echo '<div id="pictures_entry_name_'.$i.'">';
echo '<h6>'.$attachments[$i]["title"].'</h6></div>';
echo '</div>';
}}?>

I want to hide the pictures_entry_name_'.$i. and when a user clicks on a picture <a href="'.$attachments[$i]["location"].'" title="'.$attachments[$i]["title"].'" rel="prettyPhoto[gallery]"><img src="'.$attachments[$i]["location"].'" width="128" height="120" alt="'.get_the_title().'" /></a>,
I want to slide down the pictures_entry_name_'.$i of this picture.

View 5 Replies View Related

JQuery :: Toggle Function - Hide/show Table When Hide/show Button Is Pressed

Sep 12, 2011

I am trying to hide/show table when hide/show button is pressed

Problem: The code works fine when I remove 'slow' from line 10. But with 'slow' in line 10 content of toggleButton doesnt change from Hide to Show when pressed.

Code:

View 1 Replies View Related

JQuery :: Show/Hide Without The Click Function?

Aug 1, 2011

I am trying to create a simple splash page.

I have 2 divs on the page, div1 has a gif animation in it and div2 is the page content. I want to hide div2 and only show div1 which plays the gif, then after some time div1 fades away and div2 fades up to show the page content.

This is my thought process:

1) On doc ready, hide div2
2) after 3000 fade div1 out
3) fade div2 in

$(document).ready (function(){
$('#div2')hide();

but I dont know how to fade out the div after a time and fade in the other div.

The examples I see all use the click function.

View 1 Replies View Related

JQuery :: Async Function During - .show - .hide - .slidetoggle?

Jan 7, 2011

I have a table that Im hiding during the initial load that has a considerable amount of data. (I dont design'em, I just code 'em).

During the .show, .hide ... functions I would like to display a please wait msg. But I cant seem to find a way to do an async function. As the callback functions only deal with sync ...(I think)

View 1 Replies View Related

JQuery :: Function .show/hide Not Working In Chrome/IE8 But Fine In FF?

Mar 5, 2011

just started using jQuery,and i'm having a problem using the function .show()/.hide() to make a div appear and disapear when a certain option value is selected.It's working fine in firefox but not working at all in chrome and IE 8.This is the function code i'm using :

$(function(){
$("#produtos").click(function(){
$("#produtos_valor").show("slow");

[code]....

View 3 Replies View Related

JQuery :: Ajax Load Function - Show / Hide Report DIV

Jul 28, 2009

I have a function that uses the ajax load function to post off some parameters and fill a div with the returned content after a db query has been run to create it. This all works fine, however I would like to be able to replace the div with a loading graphic whilst the content
is generated. I assumed this was done by placing the graphic at the start of the function, then using a callback function to remove it and display the actual data once it has been fully generated...

However when I trey to implement this I am getting a strange result in that the callback fires before the content is generated. So my loading graphic disappears and then the content appears sometimes 10 seconds later. How can I ensure the call back only executes once the new content is
ready to be displayed ??

Here's my code ...
function get_report(){
// Hide #report_here div and show loading graphic here ...
$("#report_here").load("/admin/reports/statistics_report/", {
// Parameters sent go here
}, finished()
);
function finished() {
// Hide loading graphic and show #report_here div here ...
}

View 1 Replies View Related

Show And Hide Function

Nov 9, 2005

I need an 'unobstrusive DOM' function which will show and hide a piece of text within the DIV activated by links. Can anyone help me find a suitable function?

<div id="formatting">
<h3>Formatting options</h3>

<dl>
<dt>Bold</dt>
<dd>[b]text[eb]</dd>
<dt>Italic</dt>
<dd>[i]text[ei]</dd>
<dt>Link</dt>
<dd>link [l=url]text[el]</dd>
<dt>Line break</dt>
<dd>single new line</dd>
<dt>Paragraph</dt>
<dd>double new line</dd>

</dl>

<a href="">Show</a>
<a href="">Hide</a>

</div>

View 24 Replies View Related

Div Hide Show Function?

Jul 4, 2011

give me a dive hide show javascript function.

View 1 Replies View Related

A Menu With A Show And Hide Function

Jan 8, 2003

The below is a menu, which is hidden until clicked, and can be hidden by clicking it again.

<!-- This goes in the HEAD of the html file -->
<script language="javascript">
<!--
function showIt() {
if (document.layers) {document.layers["layer1"].visibility='hide'}
else {document.all["layer1"].style.visibility='hidden'}
}
function hideIt() {
if (document.layers) {document.layers["layer1"].visibility='show'}
else {document.all["layer1"].style.visibility='visible'}
}
// -->
</script>

<style>
input {border-style: ridge;}
a:hover {text-decoration: underline}
</style>
</head>
<body>

<span id="layer" style="position:absolute; top:17; left:20; width:250; height:90; visibility:show">
<script>
<!-- author: bfsog@hotmail.com use it as you wish //-->
<!--
function buttonText(type) {
if (type=="Hide Menu ") {document.menu.button.value="Menu";}
else {document.menu.button.value="Hide Menu ";}
showIt();
if (document.menu.button.value=="Hide Menu ") {hideIt();}
}
// -->

<!-- change the value of 'top' and 'left' in the layers properties below to place the menu
in the desired position matching the placement of the button -->
</script>


<form name="menu">
<input type="button" name="button" onClick="buttonText(value);" value="Show Menu" />
</form>
</span>
<div id="layer1" style="position:absolute; top:40; left:20; width:250; height:90; visibility:hidden">
<table bgcolor="yellow" border="1" cellpadding="2" cellspacing="0">

<tr><td><a href="http://www.google.com" style="text-decoration: none"><font face="arial" size="1"><b>google</b></font></a></td></tr>
<tr><td><a href="http://www.hotmail.com" style="text-decoration: none"><font face="arial" size="1"><b>hotmail</b></font></a></td></tr>
</table>
</div>
</body>

View 1 Replies View Related

Hide / Show Various DIV Based On Function

Aug 6, 2009

I have a script to show and hide various divs based on a function & var. The problem I am having is that when ANY of the variables ('hate', 'ok' and 'love') are passed all 3 different feedback forms ('FeedbackHate', 'FeedbackOk' and 'FeedbackLove') appear, not just the one I want.

Here is the JS:
function sitesurveyswitch(emotion) {
var e = emotion;
document.getElementById('site_survey_hate').style.backgroundPosition = '0px 0px';
document.getElementById('site_survey_ok').style.backgroundPosition = '0px 0px';
document.getElementById('site_survey_love').style.backgroundPosition = '0px 0px';
document.getElementById('FeedbackHate').style.display = 'none';
document.getElementById('FeedbackOk').style.display = 'none';
document.getElementById('FeedbackLove').style.display = 'none';
if (e == 'hate')
document.getElementById('site_survey_hate').style.backgroundPosition = '-80px 0px';
document.getElementById('FeedbackHate').style.display = 'block';
if (e == 'ok')
document.getElementById('site_survey_ok').style.backgroundPosition = '-80px 0px';
document.getElementById('FeedbackOk').style.display = 'block';
if (e == 'love')
document.getElementById('site_survey_love').style.backgroundPosition = '-80px 0px';
document.getElementById('FeedbackLove').style.display = 'block';
}

And here is the code related to this function:
<div id="siteSurveyBox">
<span id="site_survey_hate" onclick="sitesurveyswitch('hate');return false;"></span>
<span id="site_survey_ok" onclick="sitesurveyswitch('ok');return false;"></span>
<span id="site_survey_love" onclick="sitesurveyswitch('love');return false;"></span>
</div>
<div id="FeedbackHate" style="display:none; margin-top:-28px;">
FEEDBACK FORM IS HERE
</div>

<div id="FeedbackOk" style="display:none; margin-top:-28px;">
FEEDBACK FORM IS HERE
</div>
<div id="FeedbackLove" style="display:none; margin-top:-28px;">
FEEDBACK FORM IS HERE
</div>

View 2 Replies View Related

Boolean Function To Hide / Show DIV

Mar 20, 2010

I am very new to javascript and html. I am trying to create a function which will hide or show a div (div1). Right now, it is always showing the div whether the boolean value is true or false. I know that it is getting inside the else if part, but it doesn't seem to be working.

<script type="text/javascript">
function hideDiv(flag){
if (flag == false){
document.getElementById('div1').style.visibility="visible";
}else if (flag == true){
document.getElementById(div1).style.visibility="hidden";
}}
var bool = new Boolean(true)
hideDiv(bool);
</script><body>
<div id="div1">
Text!
</div></body>

View 4 Replies View Related

Calling A Function To Hide / Show Comments

Jul 19, 2009

So in the past I've mostly just copy and pasted other JavaScript functions I needed, and made slight modifications based on my exact needs. However, this time I couldn't find anything that would work with what I wanted to do (show and hide comments on news stories in a particular way), so I decided to just make my own.After a few hours of messing around with it, I'm quite exasperated, because what I have looks like it should work, but for some reason I can't identify, doesn't.Essentially what it should do is, find the table with the ID of the news article whose comments are being toggled, then find all the rows in the table that are labeled as comments, and either show them or hide them, based on their current state (as defined by their class with a "display: none;" in it or not).

Obviously it uses PHP, but I know that's not the problem; it just uses the article's ID number to pass on which comments need to be hidden/shown to the function.From everything I've looked up, this should work, but doesn't. Something peculiar, though, is that the function looks like it's not even being called; I put a simple alert('Test'); in the function, and still nothing happened when I clicked the link. So maybe my function is fine in itself, but I'm just calling it in an incorrect manner?

View 4 Replies View Related

Show/hide Function Not Working In Firefox

Feb 2, 2011

Getting my show/hide function to work in all browsers.

The function below works everywhere but Firefox.

Can someone see why it's not working?

My javascript function:

View 6 Replies View Related

Using Prototype Framework With Hide And Show Function

Mar 22, 2010

I'm learning how to use Javascripts and using Prototype framework by following a step by step tutorial from a book. Unfortunately when I stepping through the following code:[code]

View 8 Replies View Related

Function To Hide/show Multiple Rows Of Table ?

Jun 14, 2011

I have a table that contains many rows, some in italian with code <td nome='riga_i'>. and some in english with code <td name='row_e'>. I have created two buttons with different background flags: italy and uk, so when one pushes the button with flag uk, the html page will be reloaded with only english rows, and when one pushes the button with flag it, the same page is reloaded containing only italian rows. All the code posted here works well, but I think that the code can be better because to reach this result I had to dupplicate the same function and I don' t like this.

Here the code:

To better the code I have tried in this way but without success ...

View 2 Replies View Related

Function To Hide/show Multiple Rows Of Table - Created Two Buttons With Different Background Flags

Jun 13, 2011

I have a table that contains many rows, some in italian with code <td nome='riga_i'> and some in english with code <td name='row_e'>. I have created two buttons with different background flags: italy and uk, so when one pushes the button with flag uk, the html page will be reloaded with only english rows, and when one pushes the button with flag it, the same page is reloaded containing only italian rows. All the code posted here works well, but I think that the code can be better because to reach this result I had to dupplicate the same function and I don' t like this.

Here the code:

To better the code I have tried in this way but without success ...

View 1 Replies View Related

Php Within Echo Statement - Hide Element

Jul 2, 2009

I am wondering if someone could give me a quick hand with some php im trying to edit in Wordpress.

Heres the original peice I am trying to edit:

What I want to do is when "the_author" equals "admin" for the div to be hidden or deleted.

I have added this to make sure that it can find admin

My question I guess would be is there a statement that would be able to hide/delete the div? Or should I be re-writing this code, like this...

View 2 Replies View Related

JQuery :: Can The Click() Function Be Used In An If Statement

May 25, 2009

I would like to know whether a jquery click function can be used in an"if" statement.The reason why I am asking, is because I haven't seenany examples of this being done on the web. I want to use thisapproach because currently Jquery keeps initiating two events from onemouse click, eventhough the css for each element is different.Ithink the best way to avoid this problem is to use flow control toexclude the other mouse click event. If element A is clicked then

View 3 Replies View Related

JQuery :: If Then Statement Not Working Within A Success Function

Apr 29, 2010

Why my page is not redirecting within the if then statement.

Here is the code:

I have tried this without the if then statement and it works fine. I am not sure why my if then statement will not work within success function, am I doing something wrong?

View 10 Replies View Related

JQuery :: Using Click Function How To Add Or Statement Syntax?

Dec 4, 2009

I have an ID like this: $('#id').click(function(event){Do stuff after click

}); Can I have it also have a conditional or statement

$('#id').click || $variabe=='something' (function(event){
});

What is the proper syntax for something like that?

View 5 Replies View Related

Show / Hide Won't Show In Nested List

Jan 22, 2009

I am having problems, basically I have a set of nested lists I need to show and hide

Code:
<ul id="smenu3"><ul id="smenu4">
<li>stuff here..</li>
<li>stuff here..</li>
<li>stuff here..</li>
</ul><ul id="smenu5">
[Code]...

I always want "smenu3" to show with "smenu4" and "smenu5" collapsed... When the user clicks the link, it calls a javascript function to show "smenu4" like so...

[Code]...

View 7 Replies View Related

JQuery :: Hide All But One Div Show Again?

Apr 10, 2011

I have some divs laid on top of each other. By clicking somewehre specific I want to hide all the divs but except for one - which is related to the point i clicked - to show up.Here is my code so far:The function will be called by something like this:

<a href="javascript:void(0)"><img src="album_emilia.jpg" width="90px" height="125px" onclick="setAlbum('emilia')"/><p>Emilia</p></a>
function setAlbum(album) {
$('.right_nav').each(function() {[code].....

All these divs are in the same from the right_nav-class.I guess the problem lies within line 6, where I want to select the div that should show up and is given as the argument of the function.The commented lines are things I already tried, but didn't work either, especially $(this).style seems to be invalid.It does hide all divs as i want, but the one i want to show again doesn't show up. It just stays hidden...

View 9 Replies View Related

JQuery :: Show One Row & Hide Others?

Jul 3, 2009

I got this example code which show rows when click on it, the problem is it shows all but I want if I click on one row it shows that one and hide others.

<head>
<title>Jquery Table Display</title>
<script type="text/javascript" src="jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="jquery.tabledisplay-0.2.js"></script>

[Code].....

View 2 Replies View Related

JQuery :: Show/Hide A Div In IE6/7?

Mar 23, 2011

i searched the forum, but did not find a working solution for my problem. IE6/7 are not hiding the divs in the $(document).ready function. Tried also:

$("#closed").css('display', 'none'); document.getElementById('closed').style.display = 'none'; It is working when i add the ID "closed" to the <li>-Element instead of the <div>-Container. All other browsers are working fine.

[Code]...

View 2 Replies View Related

JQuery :: Show / Hide Different Div's?

May 14, 2011

the box. Anybody know what's wrong?i have the following code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

[code]....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved