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);
});
line should be:
$('#' + id + ', #underlay').fadeIn(400);
otherwise you're trying to find all <id>
elements :)
精彩评论