Javascript Element - 如何創(chuàng)建具有特定ID標(biāo)簽的DIV數(shù)組
我們想知道如何創(chuàng)建具有特定ID標(biāo)簽的DIV數(shù)組。
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.7.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){
var arr = $('div[id^="refresh"]').map(function(){ return this.id;}).get().join(',');
document.writeln(arr);
});
</script>
</head>
<body>
<div id='refresh5'></div>
<div id='refresh12'></div>
<div id='red'></div>
</body>
</html>
The code above is rendered as follows: