JavaScript: How can i set a variable in a string -
i set attributes on elements id starts "id-" followed number [e.g. id="id-0", id="id-1) , on]. thought this:
<script type="text/javascript" > function prepare() { var = 0 while(document.getelementbyid("id-{var}")) { document.getelementbyid("id-{var}").setattribute("rows", "60"); var += 1 } </script> how can set var in javascript?
this should accomplish task:
<script type="text/javascript" > function prepare() { var ct = 0 while(document.getelementbyid("id-"+ct)) { document.getelementbyid("id-"+ct).setattribute("rows", "60"); ct += 1 } </script> alternatively:
<script type="text/javascript" > function prepare() { for(var ct = 0;document.getelementbyid("id-"+ct);ct++) { document.getelementbyid("id-"+ct).setattribute("rows", "60"); } </script> javascript
No comments:
Post a Comment