Jump to content

TD fade effect


arunpatal

Recommended Posts

I have already spend 1hour to look this but no luck....

 

anyways my table look like this..

 

and i want all menu td with fade effect........

if anyone know then let me know....

till then i am searching :(

 

<table id="header_table">
 <tr>
   <td height="81" id="header_left_td"> </td>
   <td colspan="7" id="header_right_td"> </td>
 </tr>
 <tr>

<td id="top_menu_first_td" onclick="document.location.href='style/demo_php/return_data_javascript.php';" style="cursor:pointer;cursor:hand">❆
   Admin Login ❆</td>


<td id="top_menu_td" onclick="document.location.href='add_cat.php';" style="cursor:pointer;cursor:hand">❆
   Add New Category ❆</td>


 <td id="top_menu_td" onclick="document.location.href='list_cat.php';" style="cursor:pointer;cursor:hand">❆
  Category List ❆</td>



   <td id="top_menu_td" onclick="document.location.href='add_topic.php';" style="cursor:pointer;cursor:hand">❆
   Add New Topic ❆</td>



   <td id="top_menu_td" onclick="document.location.href='select_cat.php';" style="cursor:pointer;cursor:hand">❆
   Topic List ❆</td>



   <td id="top_menu_last_td" onclick="document.location.href='test.php';" style="cursor:pointer;cursor:hand">❆
   Site Settings ❆</td>

 </tr>
</table>

Link to comment
Share on other sites

CPD's suggestion will help you learn better. But once you know what you're doing, I would still use jQuery's functions.

 

I know I need to stop just writing code for people ... Came to this realization after I wrote it. lol

Demo: http://xaotique.no-ip.org/tmp/39/

 

So .. lets look at what this would be like in jQuery quick.

$(document).ready(function()
{
   $("#myTable td").click(function()
   {
       $(this).fadeOut();
   });
});

 

If you wanted to do it the long way though, you could do something like this.

window.addEventListener("load", function()
{
function fadeOut(elm, speed)
{
	speed = speed / 100;
	elm.style.opacity = 1;

	var timer = setInterval(function()
	{
		if (Number(elm.style.opacity) - speed < 0)
		{
			elm.parentNode.removeChild(elm);
			clearInerval(timer);
		}
		else
		{
			elm.style.opacity -= speed;
		}
	}, 50);
}

var items = window.document.querySelectorAll("#myTable td");

for (var i in items)
{
	items[i].addEventListener("click", function()
	{
		fadeOut(this, 5);
	}, false);
}
}, false);

Edited by Xaotique
Link to comment
Share on other sites

You shouldn't need window.document.querySelectorAll(). The document object inherits this method so document.querySelectorAll() should be just fine.

I've always used window.document. Habit from GM scripts. lol I don't think it makes a difference, but I could be wrong.
Link to comment
Share on other sites

It works with the help of jquery :)

Thanks CPD and Xaotique

If I were you, I'd use the second method I showed. Simply because, there's no real reason to include jQuery just for a single action. Everything else you have is longhand, so you may as well just add one extra function.

 

Just my thought. Glad ya got it.

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.