Jump to content

am i in the right direction with this function?


justAnoob

Recommended Posts

Hey, I recommend checking out JQuery, you just include this library in header and open up a new world of Javascript the next generation ;-)

 

http://docs.jquery.com/Tutorials:Basic_Show_and_Hide

 

in the head section place

<head>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
   $('#<?php echo $row['item_name'];?>').hide();
});
</script>
</head>

 

to show in JQuery use the .show()

 

Hope this helps

 

 

Link to comment
Share on other sites

actually looking for something to work in conjuction with this function,

function clicked(element)
{
var div=document.getElementById(element)
if(div.style.display=='none')
div.style.display='block';
else
div.style.display='none';
return;
}

This is the click function for my divs, right now the divs are open when the page is loaded. Looking to have them closed when the page is loaded and still be able to use the function above for the clicking.

Link to comment
Share on other sites

...right now the divs are open when the page is loaded. Looking to have them closed when the page is loaded and still be able to use the function above for the clicking.

So...create them as closed. Just include style="display:none;" in all of the divs by default.

 

Then reverse the logic of your function so that it "assumes" the initial state is closed. The JavaScript style properties are not set via the inline properties. I would also modify the function to just two lines:

function clicked(element)
{
  var divObj = document.getElementById(element);
  divObj.style.display = (divObj.style.display=='block') ? 'none' : 'block';
  return;
}

 

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.