If you click either button it writes the same result. Want it to write the pet type of either depending on the button clicked.
Part of a bigger script that depends on the writing of the button element in the JS code.
Please help.
Part of a bigger script that depends on the writing of the button element in the JS code.
Please help.
Code:
<html><p>
<script>
function doit(name){
document.write('you clicked: '+ name);}
items = ["CAT", "DOG"];
for(n=0;n<items.length;n++){
item=items[n];
document.write("<button onclick=\"doit(item)\" >PET</button>"+item+'<p>')
}
</script>
</html>