3

jquery 的val()值复加怎么弄

 1 year ago
source link: https://blog.p2hp.com/archives/9128
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

jquery 的val()值复加怎么弄

var hdcval = $("#hdelsecount").val();
                        hdcval += icount + ",";
                        $("#hdelsecount").val(hdcval);

往一个隐藏域里追加值。。
原始是0
icount 是传来的数字
想是

$("#hdelsecount").val(icount+",");

以为能重复追加值,如1,2,3,4,这样,可是val()这个方法是覆盖的。不是在值里追加字符额。。那个方法是追加的呢??

$("#hdelsecount").val($("#hdelsecount").val() + icount+",")

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK