javascript - JQuery displaying only certain id Div -
i have jquery function displays div, when anchor tag id toggle_(some unique number) clicked.
$("a[id ^= 'toggle']").click(function(event){ event.preventdefault(); $("div [id ^= 'replypost']").toggle(); }); each of ids toggle and"replypost end `_(unique number) each id can separate of toggle , replypost divs.
the toggle , reply post divs displayed through while() loop.so there multipe toggle , replypost divs each of them have unique number.
so there toggle_1 , replypost_1 .
i need way display replypost_1 when toggle_1 clicked , replypost_2 when toggle_2 clicked, possible? if need me clear allow me know , time.
to display post matching numeric , hide others.
$("a[id^='toggle']").click(function(event){ event.preventdefault(); $("[id^='replypost']").hide(); $("#replypost_" + this.id.replace('toggle_', '') ).show(); }); but if posts siblings less write:
$("a[id^='toggle']").click(function(event){ event.preventdefault(); $("#replypost_" + this.id.replace('toggle_', '') ).show().siblings().hide(); }); javascript jquery html
No comments:
Post a Comment