HTML:多.appends與點擊
<h1>Favorite Animal:</h1>
<input type='text'>
<button>Answer!</button>
<div id='ans'></div>
的Javascript(jQuery的)
$(document).ready(function(){
$('button').click(function(){
$('#ans').append('<h2>Bunny</h2>')
})
})
嘿。我在想。我可以做到這一點,當我在輸入中鍵入一個數字[type ='text'],然後讓這個數字的「兔子」出現? (例如:我輸入3,單詞「bunny」出現3次)。
也許它值得一提的是所有瀏覽器都不支持'fill'方法(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill#Browser_compatibility)。 – SLePort
@SLePort - 正確,'Array.fill'在IE中不受支持,但MDN有一個polyfill – adeneo
幸運的是,jQuery解決了這個問題 – adeneo