I'm able to change the CSS ID of an item with Javascript through a simple code like this:
<div id="teststyle1">Test Text, 1-1</div>
<button type="button" onclick="document.getElementById('teststyle1').style.color='red'"> Test 1 </button>
However, when I try to add in a second line of text (like in the full example below) with the same ID, only one of them gets changed. Is there a simple fix to this issue where both of the items would be changed?
Example:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#teststyle1{
text-decoration: underline;
}
</style>
</head>
<body>
<div id="teststyle1">Test Text, 1-1</div>
<div id="teststyle1">Test Text, 1-2</div>
<button type="button" onclick="document.getElementById('teststyle1').style.color='red'">Test 1</button>
</body>
</html>
Any help is greatly appreciated!