26 lis 2010

Odczyt atrybutów diva

function get_idx(_this_) {
  alert(_this_.id);
  let idx;
  idx=_this_.parentNode.parentNode.firstChild.getAttribute('d_idx');
  alert(idx);
  idx=_this_.parentNode.parentNode.firstChild.
    nextSibling.
    getAttribute('d_idx');
  alert(idx);
  return false;
}
.a { width: 200px; border: 1px solid; height: 40px; float: left; }
.b,.c { border: 1px solid; width: 40px; height: 40px; float: left; }
<div d_idx="1">
  <div d_idx="2">test 123456</div>
  <div d_idx="3">123</div>
  <div><a id="test1" href="#" onClick="get_idx(this)">usuń</a></div>
</div>
26 lis 2010

Ustawienie trzech tagów div w lini

.a {
 width: 200px;
 border: 1px solid;
 height: 40px;
 float: left;
}

.b,.c {
 border: 1px solid;
 width: 40px;
 height: 40px;
 float: left;
}
<div class="a">test 123456</div>
<div class="b">123</div>
<div class="c">123</div>
.a {
 width: 200px;
 border: 1px solid;
 height: 40px;
 float: left;
}

.b,.c {
 border: 1px solid;
 width: 40px;
 height: 40px;
 float: left;
}
<span class="a">test 12345</span>
<span class="b">123</span>
<span class="c">123</span>