Jqueryでコントロールを動的に追加し、値を取ります。
9549 ワード
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
runat
="server"
>
<
title
>
Jquery
</
title
>
<
script
src
="jquery-1.4.2.js"
type
="text/javascript"
></
script
>
<
script
type
="text/javascript"
>
$(
function
() {
var
i
=
2
;
$(
'
#addText
'
).click(
function
() {
if
(i
<
9
) {
$(
'
#main
'
).append(
'
<div><input type="text" name="text" + i + ""/>
<a href="#" class="del-text">del</a></div>
'
);
i
++
;
}
else
{
alert(
"
8
"
);
}
});
$(
'
.del-text
'
).live(
'
click
'
,
function
(){
$(
this
).parent().remove();
i
--
;
});
});
</
script
>
</
head
>
<
body
>
<
div
id
="main"
>
<
div
>
<
input
type
="text"
name
="text1"
/>
</
div
>
</
div
>
<
a
id
="addText"
href
="#"
>
</
a
>
</
body
>
</
html
>
=============値を取るのは簡単です。楽屋で直接使います。 Request["text"+i].ToStering()で結構です。