开发者

jQuery change and modify ID attribute and fadeIn

开发者 https://www.devze.com 2023-02-23 03:01 出处:网络
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 i

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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号