0

I want to add value on every click on my function.

for example i click on then value is coming but i want to click again and another value should come without replacing the existing value

  <script>
    function dearq(selected){

      var value = $(".textvaluenonw").val();
          $("#dearname").html(value);

    }

</script>

here is the fiddle

http://jsfiddle.net/r7P3w/12/

4

3 回答 3

2

如果要在#dearName元素中添加文本,只需使用$.append().

function dearq(selected){

    var value = $(".textvaluenonw").val();
    $("#dearname").append(value);

}
于 2012-09-13T11:59:20.830 回答
0

获取文本并追加

<script>
function dearq(selected){

  var value = $(".textvaluenonw").val();
  var newValue=$("#dearname").text()+" " + value;
      $("#dearname").html(newValue);

}

</script>
于 2012-09-13T11:59:26.900 回答
0

尝试:

  <script> 
    function dearq(selected){ 
      var value = $(".textvaluenonw").val(); 
      $("#dearname").append(value); 
    } 
</script> 
于 2012-09-13T12:00:32.673 回答