javascript - justify - Best approach -


webkit browser not supported "ruby of justify".

i found javascript (https://code.google.com/p/justify/).

as result of using this, new problem has occurred...

  <ul id="list">   <li>    <h3 id="main"><ruby>lorem<rt id="sub">ipsum</rt></ruby></h3>    <p>lorem ipsum dolor sit amet...... </p>   </li>  </ul> 

this fine. script used "document.getelementbyid".

when element increased, of course, not work.

when rewrite "document.getelementbyid" "document.getelementsbyclass", uncaught typeerror: object #<nodelist> has no method...

when element increased, do?

(sorry... i'm not @ english)

uncaught typeerror: object #<nodelist> has no method... 

this error occurs because trying treat list of nodes single node. because forgetting element out of result of getelementsbyclassname.

getelementbyid returns single dom element, getelementsbyclassname returns list (array-like object) of dom elements. have index latter, not former.

<div class="foo" id="bar"></div>  <script> alert(     document.getelementbyid('bar')   // 1 result @ most, no [0].     ===     // classname, not class.  [0] since result list.     document.getelementsbyclassname('foo')[0] ); </script> 

should alert "true"


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -