technopeasant
technopeasant

Reputation: 7959

jQuery change and modify ID attribute and fadeIn

I've got a function that dynamically fades an element in based on the ID of the link you clicked. That is to say.. you click a link with an id of "show_tide" and the function drops "show_" from it and fades in what's left of the id. "show_tide" turns into "tide".

I'm having some kind of syntax error and can't figure out what it is.. help?

Thank you!

HTML:

<img id="show_tide" class="vid" src"#">
<iframe id="tide" class="vim" src="http://google.com"></iframe>

JavaScript:

$('.vim, #underlay').hide();

$('.vid').click(function() {
    var id = $(this).attr("id").replace("show_","").toLowerCase();
    $('id, #underlay').fadeIn(400);
});

$('#underlay').click(function() {
    $('.vim, #underlay').fadeOut(400);
});

Upvotes: 1

Views: 535

Answers (1)

user578895
user578895

Reputation:

line should be:

$('#' + id + ', #underlay').fadeIn(400);

otherwise you're trying to find all <id> elements :)

Upvotes: 2

Related Questions