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

 

 

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.

...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;
}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.