Forum Moderators: open

Message Too Old, No Replies

title attribute of a link added to a text field or div

!important really need help

         

tarairvine

1:51 pm on Aug 9, 2010 (gmt 0)

10+ Year Member



I am using wordpress and I have a set of images each with a different title attribute, I need to add the title attribute from the images to a div positioned absolutely.

Any ideas on how to do this? When I mouse out it must! update. When I mouse over the title of that link appears in the div and disappears on mouseout/.

Fotiman

2:05 pm on Aug 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You'll need to attach event listeners to the mouseover and mouseout events and set the innerHTML of the div element. Have you tried anything yet? Are you using any JavaScript libraries/frameworks (jQuery, YUI, Prototype, etc.)?

tarairvine

2:26 pm on Aug 9, 2010 (gmt 0)

10+ Year Member



using Jquery I got the innerHTML working but not dynamically.
Bit lost to be honest

Fotiman

3:34 pm on Aug 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ok, so first we'll need to attach the listeners. Are all of the images contained within a common container element that we can reference by ID? As in:

<div id="myImages">
...
<img ...>
<img ...>
...
</div>


If so, we can delegate the listeners to the container:


$('#myImages').delegate('img', 'mouseover', function () {
$('#titleTarget').html($(this).attr('title'));
});
$('#myImages').delegate('img', 'mouseout', function () {
$('#titleTarget').html('');
});