jquery: read div id and remove appropriate div? -
hey, had no idea title post should have, hard describe :)
i have dynamic id's number
<div id="post-full-116">content</div> <div id="post-116">content</div> i want query dynamic number (in case 116) of id="post-full-116" , if div on page id="post-116" exists want remove that.
sounds weird know. idea behind it, div id="post-number" holds preview of post , the div id="post-full-number" holds full content of post.
i don't want show preview of post if full post shown - want hide jquery. know should on serverside before, in case jquery perfect.
any idea how can query number of dynamic id , remove appropriate div same number?
thank you
i'm thinking this:
$(function() { $('[id^=post-full]').each(function() { var num = $(this).attr('id').replace(/post\-full\-/,''); $('#post-' + num).hide(); }); }); that should grab "full" posts, find number of post, , hide "preview" version of it.
update:
here's live demo of that: http://jsfiddle.net/ender/sauqf/
Comments
Post a Comment