RoboTamer
RoboTamer

Reputation: 3518

get id rather then class tag with jquery?

I found this HowTo and modified the script a bit, but I would like to select id tags rather than class tags. In other words: Right now it works for class="title", and I like it to work with id="title"

<script type="text/javascript" language="javascript">
$(function() {
    var language = '{{@LANGUAGE}}';
    $.ajax({
        url: 'vps.xml',
        success: function(xml) {
            $(xml).find('translation').each(function(){
                var id = $(this).attr('id');
                var text = $(this).find(language).text();
                $("." + id).html(text);
                $("." + id).addClass(id + '_' + language);
            });
        }
    });
});
</script>

Upvotes: 0

Views: 77

Answers (1)

Joe
Joe

Reputation: 82604

change . to a hashtag #

$("#" + id)

Upvotes: 2

Related Questions