Jump to content
php.lv forumi

Style mainisana ar JS.


slitz

Recommended Posts

Esmu pilnigs JS iesacejs, tapec prasu nelielu palidzibu, diezgan ilgi mekleju neta ka var mainit style <div> tagam. Bet neatradu.

Meginaju pats uztaisit pec saviem ieskatiem, bet tomer skripts nestrada, varbyt kads zinosaks var palidzet??

<html>
<head>
<script type="text/javascript">
function Mainitdatus()
{
document.getElementById('MainDiv').style="width:100px; hight:100px; border: 2px solid #DDDDDD;"
}
</script>
</head>
<body>
<div id="MainDiv" onclick="Mainitdatus()" style="width:100px; hight:100px; border: 2px solid #000000;">
lol lol
</div>
</body>
</html>

 

Un sekojosais errors...

setting a property that has only a getter
Mainitdatus()test.htm (line 6)
onclick(click clientX=0, clientY=0)test.htm (line 1)
[Break on this error] document.getElementById('MainDiv').style="width:100px; hight:100px; border: 2px ...

Link to comment
Share on other sites

Kā reiz ņemos ar līdzīgām darbībām un varu pāris piemērus te iebarot. Pirmkārt jau height nevis hight.

1. Tas ko v3rb0 minēja par class mainīšanu. Ērts risinājums

2.

var el = getElementById('tavsID');
el.style.width = '100px';
el.style.border = '1px dotted rgb(170, 170, 0)';

3.

var el = getElementById('tavsID');
el.setAttribute('width', '100px');

Link to comment
Share on other sites

×
×
  • Create New...