首页javascriptdivJavascript Element - 如何创建具有特定ID标签的DIV数组

Javascript Element - 如何创建具有特定ID标签的DIV数组

我们想知道如何创建具有特定ID标签的DIV数组。


<!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>