我有以下代碼。 (形式是在開始隱藏)JQuery。隱藏一個div和另一個在第一個地方
HTML
<div1 id="js_sel1">
<p> this is selct 1 </p>
<a class="js_showform" data-id="1" href="#">edit1</a>
</div>
<div2 id="js_sel2">
<p> this is select 2 </p>
<a class="js_showform" data-id="2" href="#">edit2</a>
</div>
<div3 id="js_sel3">
<p> this is select 3 </p>
<a class="js_showform" data-id="3" href="#">edit3</a>
</div>
<form id="js_form" class="js_hide_form">
<p> this is my form </p>
<a class="js_hideform" href="#">save</a>
</form>
jQuery的
$(function() {
var par = $('.js_hide_form');
$(par).hide();
$('.showform').click(function(e) {
e.preventDefault();
var hide_ele = "#js_sel" + $(this).data("id");
var show_ele = "#js_form";
$(hide_ele).hide;
$(show_ele).show;
});
$('.hideform').click(function(e) {
e.preventDefault();
var hide_ele = "#js_form";
var show_ele = "#js_sel" + $(this).data("id");
$(hide_ele).hide;
$(show_ele).show;
});
});
在啓動,form標籤是隱藏的。點擊任何編輯(如div2的編輯2),我希望特殊的div(ex div2)應該消失,表格應該出現在DIV的特定區域(這裏是div2)。
如果你能幫助我,我會非常感激。 TY :)
'div2','div3'?你怎麼能這樣做?這不是有效的HTML! – void
用您的代碼更新此https://jsfiddle.net/mohamedyousef1980/maspc1uo/ –