Link to home
Start Free TrialLog in
Avatar of gvilla23
gvilla23Flag for United States of America

asked on

Change complete href in link

I am trying to change the complete href, in Jquey  or javascript.

I am able to change the href, but it keeps part of the site url.

I change the default from javascript;; to whatever.html, but when I change it back to its original (href javascript;;) the link looks like href www.mysite.htmljavascript;;,
 not just javascript;;




 

if  (jQuery('#projects li img[style*=opacity: 1]').attr('title') == "pro173");
jQuery("#pro173").attr({
  href: 'somepage.html',
   
 })}else{
jQuery("#pro173").attr({
  href: 'javascript;;',
   
});

ASKER CERTIFIED SOLUTION
Avatar of darren-w-
darren-w-
Flag of United Kingdom of Great Britain and Northern Ireland 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
Avatar of gvilla23

ASKER

thanks, let me try it!
Avatar of leakim971
Check this :


<html>
<head>
<script src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<script>
	$(document).ready(function() {
		jQuery("li a", "#projects").each(function() {
			var found = $("img[style*='opacity:1']", this).length > 0;
			$(this).attr("href", found?"http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26896707.html":"javascript:void(0)");
		})
	});
</script>
<body>
<ul id="projects">
<li><a href="javascript:void(0)"><img src="http://www.wikidive.com/Photo/Images/guadeloupe.jpg" style="opacity:1" src="" width=320 /></a></li>
<li><a href="javascript:void(0)"><img src="http://www.wikidive.com/Photo/Images/guadeloupe.jpg" style="opacity:0.30" src="" width=320 /></a></li>
<li><a href="javascript:void(0)"><img src="http://www.wikidive.com/Photo/Images/guadeloupe.jpg" style="opacity:0.30" src="" width=320 /></a></li>
</ul>
</body>
</html>

Open in new window