kodyWiG

Tag: className

25 mar 2009

Odnajdywanie elementów według określonej klasy

var cont = document.getElementById('content').getElementsByTagName('div');
for(i=0;i<cont.length;i++)
if (cont[i].className.match(/^belka/))
  cont[i].style.display = 'none';

Przyklad ukrycia elementów, wykorzystanie match:

<div id="content">
  <div class="belka">odnajdywanie klasa belki</div>
  <div class="belka">odnajdywanie klasa belki</div>
</div>
className display getElementById getElementsByTagName match
28 lip 2008

Dodawanie stylu do utworzonego elementu strony

var element = document.getElementById(id);

var p = document.createElement("p");
var pText = document.createTextNode("Szczególy");
p.appendChild(pText);

if (p.style.setAttribute)
  p.setAttribute("className", "t");
else
  p.setAttribute("class", "t");
appendChild class className createElement setAttribute
Copyright © | kodyWiG Theme
  • JavaScript 217
  • PHP 139
  • CSS 105
  • HTML 74
  • GMap 47
  • Linux 46
  • PostgreSQL 34
  • MySQL 33
  • VBSCRIPT 32
  • jQuery 27
  • Smarty 27
  • Wordpress 27
  • Windows 24
  • SQL 19
  • htaccess 18
  • Perl 17
  • Programy 11
  • System 11
  • SQL Server 10
  • Leaflet 10
  • Rewrite 9
  • HTTP 8
  • VBA 7
  • React 7
  • Intellij IDEA 6
  • Telefony 6
  • WYSIWYG 6
  • XML 6
  • Nodejs 5
  • SVG 4
  • JSON 3
  • Docker 3
  • Rejestr 3
  • Nauka 2
  • Github 1
  • Bez kategorii 1
  • Opera 1
  • Rollup 1