![]() |
PCDVD數位科技討論區
(https://www.pcdvd.com.tw/index.php)
- 七嘴八舌異言堂
(https://www.pcdvd.com.tw/forumdisplay.php?f=12)
- - 請問文字方塊內容可以遞增嗎?
(https://www.pcdvd.com.tw/showthread.php?t=1003723)
|
---|
請問文字方塊內容可以遞增嗎?
不好意思,小弟又來這裡冒昧請教一下,
請問下面這段文字方塊語法,內容是「號碼1」, <textarea style="width: 188; width:183; height:214; " rows="2" onfocus="this.focused=true;this.select();" onmouseup="if(this.focused){this.focused=false;return false;}" cols="20" name="JYT"> 號碼1</textarea> 譬如按一下按鈕,裡面的內容就會變成「號碼2」、 再按一下變成「號碼3」、再按一下變成「號碼4」....以此類推。 請問要如何改才能實現依序遞增呢? |
hand:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script> var N=1; $(document).ready(function() { $("#Do").click(function() { N += 1; $("#JYT").val("號碼" + N); }); }); </script> body: <textarea style="width: 188; width:183; height:214; " rows="2" onfocus="this.focused=true;this.select();" onmouseup="if(this.focused){this.focused=false;return false;}" cols="20" id="JYT"> 號碼1</textarea> <div id="Do">點我</div> |
引用:
謝謝,大大真是太厲害了... :shy: 再請教一下,請問可以寫成這樣嗎? |-----------------| |號碼1 | |-----------------| 按一下按鈕 |-----------------| |號碼1 | |號碼2 | |-----------------| 按一下按鈕 |-----------------| |號碼1 | |號碼2 | |號碼3 | |-----------------| |
某行改成:
$("#JYT").val($("#JYT").val() + "\n" + "號碼" + N); |
再請教一下,
如果要再號碼+N後面加入多行文字呢? |
所有的時間均為GMT +8。 現在的時間是10:08 PM. |
vBulletin Version 3.0.1
powered_by_vbulletin 2025。