Solved

jquery - image opacity

Posted on 2008-06-18
4
7,762 Views
Last Modified: 2010-04-21
Hello Experts,
I am making an icon on the page to look pale by reducing its opacity when the user clicks on it.
something like this
$(this).animate({opacity: "0.3"}, 500);
It is working fine on the event, however it is not retaining its style when I refresh the page.
Can someone please let me know If we can do quick jQuery search if the Id of this icon exist in the menu where it has been added then keep the pale look. Please can someone advice how to check this?
Thanks for your help.
Regards
S
0
Comment
Question by:newbie27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 8

Author Comment

by:newbie27
ID: 21812637
I mean, onclick of this icon,  the Icon Id gets added to the menu in the left. please see attached


$('#shortlist').prepend('<li id="' + theId + '_li" title="'+ myTitle +'" style="background-image:url(\'\');padding-left:0"><a href="#" class="dynAdded" onclick="removeItem(this); return false;" title="Remove">&nbsp;[-]</a>' + myTitle + ' </li>');	
	$('#'+  theId + '_li').slideDown("slow");
	$('#'+ theId + '_spg').fadeOut('fast',  function(){$(this).remove()});				      
    

Open in new window

0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 21896505
For this you will need to save the clicked item id in a cookie and when the page loads then run the animate. Basically the steps would be as follow:
at loadtime
{
 obtain list of ids
foreach id in list
{
 $('#'+  id + '_li').slideDown("slow");
      $('#'+ id + '_spg').fadeOut('fast',  function(){$(this).remove()});
}
}
0
 
LVL 8

Author Closing Comment

by:newbie27
ID: 31468327
thanks hielo
0
 
LVL 8

Author Comment

by:newbie27
ID: 21906695
Hielo,
I have tried to add a function to get the values from the cookie check with added list Id,

I have added a retainImageSyle function and calling it from document ready
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23529734.html
please see and add your comments there

thanks
sam


function retainImageSyle(){
	/*
          // is this not correct ?
         var myList = getShortList();
	for(var x=0; x<myList.length; x++)
	{
		 $('#'+  myList[x].id  + '_li').slideDown("slow");
        $('#'+ myList[x].id  + '_spg').fadeOut('fast',  function(){$(this).remove()});
	}*/
	
	
	var myId = $(this).attr('id');
	var theId = myId.replace('_lnk', '');
	var myTitle =  $(this).attr('title') ;
     //   $('.addToShortList').click(function() {add2ShortList.call(this,true);});        
	//check if the item already added
	var myLi = $('#' + theId + '_li').html();
	alert(myLi);
	//if (myLi){	    
	//	$('#'+myId).mousedown(function(){$('#' + theId + '_li').css('background','#fef8a5')});
	//	$('#'+myId).mouseup(function(){$('#' + theId + '_li').css('background','')});
    //    return;
	}
}

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery form 9 62
PHP: Filling Out/Creating a PDF 29 158
How can I allow 0, 10 or 13 digits only with regular expression/javascript 2 42
JSON help 8 42
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question