Solved

Jquery select image and change link

Posted on 2011-02-28
1
483 Views
Last Modified: 2012-05-11
I need to target a images based on the image style and change its link. Thia does not work


jQuery('#projects li img [style*=opacity: 1]').attr('href', 'some link')
0
Comment
Question by:gvilla23
[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
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 250 total points
ID: 35001942
Use : jQuery('#projects li img[style*="opacity:1"]').parent("a").attr('href', 'http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/Q_26853726.html');

Test page :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script language="javascript">
	jQuery(document).ready(function() {
		jQuery('#projects li img[style*="opacity:1"]').parent("a").attr('href', 'http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/Q_26853726.html')
	});
</script>
</head>
<body>
<form id="projects">
<ul><li><a href="#"><img style="opacity:1" src="http://www.balisier148.com/photos/tortue_guadeloupe.jpg" width="160" /></a></li></ul>
</form>
</body>
</html>

Open in new window

0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

726 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