I am a beginner, so please excuse my ignorance.
I have a simple html page with the following structure.
When the image is clicked, I want to be able to get the title of the
person and add as title of the image.
I am not sure how to get the selected element 'title' and not all the
li.title class items.

My JS looks like
            $(document).ready(function(){
                $("img").click(function () {
                    $("li.title").css("text-decoration", "underline");
                    $("img").attr("title",$("li.title").text());
                });
            });


    <body>
        <ul id="infolist">
            <li>
                <a class="personName" href="#">Mary Adams</a>
                <div class="person">
                    <ul>
                        <li class="portrait">
                            <img src="images/dtv_bg.png" alt="Mary
Adams" height="30" width="30" title="asdadsa">
                        </li>
                        <li class="title">Vice President</li>
                        <li class="office">102 Bldg 1</li>
                          </li>
                    </ul>
                </div>
            </li>
            <li>
                <a class="personName" href="#">John Matthews</a>
                <div class="person">
                    <ul>
                        <li class="portrait">
                            <img src="images/dtv_bg.png" alt="John
Matthews" height="30" width="30">
                        </li>
                        <li class="title">Middle Manager</li>
                        <li class="office">307 Bldg 1</li>

Reply via email to