I would like to set attributes on all elements that id starts with “id-” followed by a number [e.g. id=”id-0″, id=”id-1) and so on]. I thought about something like 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 i set a var like this in JavaScript?
this should accomplish the task:
alternatively: