私は過去にこれと似たようなことをしました。私がしたことの1つは、最初のアイテムが最後のものを知らない "ルーティング"システムのように実装したことでした。
は、これらの要素を考慮してください。
<div id="req1" data-yes="#req2" data-no="#reqno">
Do you do stuff?
<button class="yes">Yes</button>
<button class="no">No</button>
</div>
<div id="req2" data-yes="#req3" data-no="#req1">
<!-- content here... -->
</div>
<div id="req3" data-yes="#done" data-no="">
<!-- content here... -->
</div>
... and so on
あなたは、フローの処理/順序を知るために、タグに符号化されたデータを使用するために、いくつかの一般的なjQueryのを書くことができます。 data-yes
とdata-no
の値は、ワークフローの次の要素のセレクタです。
コードはこれらを総称して使用します。効果に何か...
$('div[data-yes]').each(function() {
var container = $(this);
// Bind "YES"
container.find('button.yes').click(function() {
var next = $(container.attr('data-yes'));
next.fadeIn();
container.fadeOut();
});
// Bind "NO"
container.find('button.no').click(function() {
var next = $(container.attr('data-no'));
next.fadeIn();
container.fadeOut();
});
});
クリックハンドラthasショー:デモの作業
を/ページのさまざまな部分を非表示にする... –