admin管理员组文章数量:1026103
I have 2 text areas in my page as;
<input type="text" id="a1"/>
<textarea id="b2"></textarea>
<a id="button">button</a>
When user click the button link, I want to alert
the data entered in a1
and b2
.
How can I do this?? Here is there demo
Thanks in advance...:)
blasteralfred
I have 2 text areas in my page as;
<input type="text" id="a1"/>
<textarea id="b2"></textarea>
<a id="button">button</a>
When user click the button link, I want to alert
the data entered in a1
and b2
.
How can I do this?? Here is there demo
Thanks in advance...:)
blasteralfred
Share Improve this question asked Apr 12, 2011 at 6:41 AlfredAlfred 21.4k63 gold badges174 silver badges257 bronze badges3 Answers
Reset to default 5 $(document).ready(function() {
$('#button').click(function(e) {
e.preventDefault();
alert($('#a1').val());
alert($('#b2').val());
});
});
dont use same id a1
for <a id="button">button</a>
and <input type="text" id="a1"/>
and you can use jquery val()
function to get value
alert($('#a1').val());
alert($('#b2').val());
Do like this :
window.alert($("#a1").val());
window.alert($("#a2").val());
Your code should appear likt this :
<input type="text" id="a1"/>
<textarea id="b2"></textarea>
<a id="button" onclick="window.alert($('#a1').val());window.alert($('#a2').val());return false;">button</a>
I have 2 text areas in my page as;
<input type="text" id="a1"/>
<textarea id="b2"></textarea>
<a id="button">button</a>
When user click the button link, I want to alert
the data entered in a1
and b2
.
How can I do this?? Here is there demo
Thanks in advance...:)
blasteralfred
I have 2 text areas in my page as;
<input type="text" id="a1"/>
<textarea id="b2"></textarea>
<a id="button">button</a>
When user click the button link, I want to alert
the data entered in a1
and b2
.
How can I do this?? Here is there demo
Thanks in advance...:)
blasteralfred
Share Improve this question asked Apr 12, 2011 at 6:41 AlfredAlfred 21.4k63 gold badges174 silver badges257 bronze badges3 Answers
Reset to default 5 $(document).ready(function() {
$('#button').click(function(e) {
e.preventDefault();
alert($('#a1').val());
alert($('#b2').val());
});
});
dont use same id a1
for <a id="button">button</a>
and <input type="text" id="a1"/>
and you can use jquery val()
function to get value
alert($('#a1').val());
alert($('#b2').val());
Do like this :
window.alert($("#a1").val());
window.alert($("#a2").val());
Your code should appear likt this :
<input type="text" id="a1"/>
<textarea id="b2"></textarea>
<a id="button" onclick="window.alert($('#a1').val());window.alert($('#a2').val());return false;">button</a>
本文标签: javascriptget text area and text field datajqueryStack Overflow
版权声明:本文标题:javascript - get text area and text field data - jquery - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745629940a2160099.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论