Jquery实现点击按钮,连续地向textarea中添加值的实例代码_jquery

WBOY
Release: 2016-05-16 16:56:15
Original
1233 people have browsed it

代码如下:

复制代码代码如下:

pageEncoding="gbk"%>




$(document).ready(function(){
$("input[id^='buttonValidate']").click(function(){ //当点击所有的id中包含'buttonValidate'的input标签时,执行函数
var btnVal=$.trim($(this).val());//trim函数,去掉空格
var str = $('#textareaValidate').val() + btnVal;//
$('#textareaValidate').val(str);//
});
});

Insert title here































以上实现的功能:点击+,则把+添加到textarea中,点击-,则把-添加到textarea中;

如图:

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!