Bir sayfadaki butun css class isimlerini gostermek (How do you list all of the CSS class names in a document?)

Friday, June 27, 2008 13:31
Posted in category Javascript



Kimi zaman işe yarayabilecek bir javascript bir sayfadaki butun class isimlerini javascript ile yazdırmak.

var allTags = document.body.getElementsByTagName(‘*’);
 var classNames = {};
 for (var tg = 0; tg< allTags.length; tg++) {
    var tag = allTags[tg];
    if (tag.className) {
  var classes = tag.className.split(" ");
 for (var cn = 0; cn < classes.length; cn++){
 var cName = classes[cn];
 if (! classNames[cName]) {
 classNames[cName] = true;
 }
 }
 }
 }
 var classList = [];
 for (var name in classNames) classList.push(name);
 alert(classList);
 document.write(classList);
You can leave a response, or trackback from your own site.

2 Responses to “Bir sayfadaki butun css class isimlerini gostermek (How do you list all of the CSS class names in a document?)”

  1. css says:

    August 12th, 2008 at 10:26 pm

    CSS “Cascading Style Sheets” Lessons
    css list style Properties and examples — http://css-lessons.ucoz.com/list-css-examples.htm

  2. admin says:

    August 26th, 2008 at 7:04 am

    arkadasım ne alakası var?

Leave a Reply