The Riot
The Riot

Reputation: 41

jQuery attr replace on aspx

I work with php/mysql and of course BUT one guy called me yesterday with a problem that a can't solve

he have this code:

<a href='#'  class="fancybox-effects-d classelink">
    <telerik:RadBinaryImage 
    runat="server"
    Style="width: 100%; height: auto;" 
    ID='RadBinaryImage' 
    DataValue='<%#Eval("IMAGEM")%>'
    AutoAdjustImageControlSize="false"
    ToolTip='<%#Eval("TITULO")%>'
    AlternateImage='<%#Eval("IMAGEM") %>'
    ResizeMode="crop" modal="true" />
</a>

he want to replace de href="#" with the src from the image i don't have any idea of how to do that, i tried jquery but i failed

Upvotes: 0

Views: 77

Answers (1)

John-M
John-M

Reputation: 653

I think jQuery is a good way to do this, you wouldn't need to really modify the html or asp at all:

$(function() {
    $('a.fancybox-effects-d.classelink').each(function(index, element) {
        $(this).attr('href', $(this).find('img').attr('src'));
    });
});

If there are lots of 'fancybox-effects-d' and 'classelink' classed elements just add a special class for all of the a tags in question-- adding an ID can definitely work too if you did it in the html markup

Upvotes: 1

Related Questions