jqueryの初心者です..私はこのhtmlコードを持っています
<div id='input'>
<table>
<tr>
<td class="number">
<input><input><input><input><br>
</td>
<td style="vertical-align:bottom"><button>+</button></td>
</tr>
<tr>
<td class="number">
<input><input><input><input><br>
</td>
<td style="vertical-align:bottom"><button>+</button></td>
</tr>
</table>
</div>
そして私のスクリプト部分のために
jQuery.fn.vcenter = function(parent) {
if (parent) {
parent = this.parent();
} else {
parent = window;
}
this.css({
"position": "absolute",
"left": ((($(parent).width() - this.outerWidth()) / 2) + $(parent).scrollLeft() + "px"),
});
return this;
}
jQuery.fn.hcenter = function(parent) {
if (parent) {
parent = this.parent();
} else {
parent = window;
}
this.css({
"position": "absolute",
"top": ((($(parent).height() - this.outerHeight()) / 2) + $(parent).scrollTop() + "px"),
});
return this;
}
jQuery.fn.center = function(parent) {
if (parent) {
parent = this.parent();
} else {
parent = window;
}
this.css({
"position": "absolute",
"top": ((($(parent).height() - this.outerHeight()) / 2) + $(parent).scrollTop() + "px"),
"left": ((($(parent).width() - this.outerWidth()) / 2) + $(parent).scrollLeft() + "px"),
});
return this;
}
$(document).ready(function(){
$("#input").vcenter(true);
});
$("#input:button").click(this.parent().prev().html()+="<input><input><input><input><br>");
基本的にやろうとしているのは、IDが「input」の要素内のボタンをクリックするたびに
、スクリプトが次のように実行することです。スクリプトは親要素()に移動し、次に前の兄弟に移動します。次に、そのhtml内部に次のように追加します。"<input><input><input><input><br>"
宿題を済ませました。そして私は助けが必要です!ここで何が問題になっていますか?