Blast
Blast

Reputation: 955

Can't find path of the img inside div

I want to get path of image and assing it to the src of manset_foto I have this code I could not find what is wrong.

<script type="text/javascript">
     $(document).ready(function () {

     var path = $('div#onIzlemeler img:first-child').attr('src');

    $('#manset_foto').css('display', 'none').fadeIn('slow').attr('src', path);
    $('div#onIzlemeler img').mouseenter(function () {
      $('#manset_foto').css('display', 'none').fadeIn('slow').attr('src', $(this).att('src'));
                });
            });
</script>

<div id="onIzlemeler">
    <img src="slider/1.jpg" alt="" />
    <img src="slider/2.jpg" alt="" />
    <img src="slider/3.jpg" alt="abla" />
    <img src="slider/4.jpg" alt="!" />
    <img src="slider/5.jpg" alt="" />
</div>

 <div id="manset">
        <img id="manset_foto"/>
        <p id="manset_bilgi"></p>
    </div>

Upvotes: 0

Views: 333

Answers (2)

Jai
Jai

Reputation: 74748

Seems you are missing "r" of .attr() method here:

$('#manset_foto').css('display', 'none').fadeIn('slow')
                 .attr('src', $(this).att('src'));
                //----------------------^----here "r" is missing in .attr()

Upvotes: 1

Satpal
Satpal

Reputation: 133453

You need to use variable path

 var path = $('div#onIzlemeler img:first-child').attr('src');
 $('#manset_foto').css('display', 'none').fadeIn('slow').attr('src', path);

Currently You are using yol

EDIT

use .attr() instead of .att()

Your other mistake is in line .attr('src', $(this).att('src'))

DEMO

Upvotes: 2

Related Questions