Link to home
Start Free TrialLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

jquery - image opacity

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
Avatar of newbie27
newbie27
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks hielo
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
https://www.experts-exchange.com/questions/23529734/jQuery-Image-opacity.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