Hi, I have this sites: index.html with this code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript" src="
http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
function loadContent(elementSelector, sourceUrl) {
jQuery(elementSelector).load(sourceUrl, myInit);
}
</script>
</head>
<body>
<div id="menu">
<a href="javascript:loadContent('#content', 'selectors.html');">selectors</a><br/>
</div>
<div id="content">
</div>
</body>
</html>
and on selectors.html I have this:
<img src="imgs/image.jpg" class="myPicture" title="no text 1"/><span class="myClass">1. span</span><br/>
<img src="imgs/image.jpg" class="myPicture" title="no text 2"/><span class="myClass">2. span</span><br/>
<img src="imgs/image.jpg" class="myPicture" title="no text 3"/><span class="myClass">3. span</span><br/>
<button onclick="setTitleToImage(1);">Set title</button>
<script>
function setTitleToImage(myIndex) {
var spanValue = jQuery('.myClass').get(myIndex).text();
jQuery('.myPicture').get(myIndex).attr('title', spanValue);
}
</script>
what I need is set an image title with given index (1) with value of span with given index (1). I tried some laborations with gt(), index(), but there is no success. This code is not running too:-( Can anybody help me?
Thanks