0

I a search result page. This search result page is a table. I can not change the html of the page. This is the html:

<table class="product-table">
    <tr>
        <td>
            <dl>
                <dt>
                    <h1>Item</h1>
                </dt>

                <dd class="title fn">
                    <a class="url" href="/product.jsp?id=EHS_FR_BS-PK-409674&amp;navAction=jump&amp;navCount=0">
                        Pratique de l'accouchement, 5ème Edition
                    </a>
                </dd>
            </dl>
        </td>
    </tr>
    <tr>
        <td>
            <dl>
                <dt>
                    <h1>Item</h1>
                </dt>

                <dd class="title fn">
                    <a class="url" href="/product.jsp?id=EHS_FR_BS-PK-409674&amp;navAction=jump&amp;navCount=0">
                        Pratique de l'accouchement, 5ème Edition
                    </a>
                </dd>
            </dl>
        </td>
    </tr>
</table>

My Question

But i want in the dd class title fn. A new element. This a element is a link to more information of the page. The element must get the href of the a class=url element.

I make this javascript:

 $("table.product-table .pricing").append('<a class="information" href="" title="plus d’information">plus d’information</a>');

But how can i fix this better. And how can i put the href of the class url in the new a element that i append.

Do you understand my question??

Thanks for helping!

2
  • why are you using a class "pricing" inside the jquery selector? this elements does not seem to exist in your given html Commented Sep 28, 2011 at 6:36
  • You already have a link to the resource, why are you duplicating it? Commented Sep 28, 2011 at 6:42

1 Answer 1

1
$("dd.title.fn").each(function() {
    var $this = $(this);
    $this.append('<a class="information" href="' + $this.find(".url").attr("href") + '" title="plus d’information">plus d’information</a>');
});

Does this help you? Check out this link for more information on each method which might help you getting the url of each link you want to append.

http://api.jquery.com/jQuery.each/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.