0

I have this line of code

var songs = document.getElementsByTagName("span");
var songArray = jQuery.makeArray(songs);
$(songArray).appendTo(document.body);   

Which looks for span tags on a page, creates an array then displays them. I don't know if that's the best way to do it but it works. But the problem I'm having is I want to display the array and if there is a duplicate in that array, it deletes the duplicate and increases the font size of the first instance of it. Not sure how to get that done.

4

1 回答 1

0

下面的代码将选择所有spans 并将它们添加到正文中,除非添加了具有相同“值”的跨度,在这种情况下,字体大小将设置为larger但是函数 'getValue' 保留为“练习”,因为缺乏关于什么构成重复的信息

var songs = $("span")
    temp = {};
songs.each(function(){
  var value = getValue(this);
  if(!temp.hasOwnProperty()){
     (temp[value] = $(this).clone())
       .appendTo(document.body);
  } else {
     temp[value].css({"font-size":"larger"})
  }
});
于 2013-04-17T17:59:48.397 回答