Hello i've got a problem with the selectors in jquery. I made a minimal example in the following, where you can click the buttons and change the color of the targets next to the buttons. I cannot specifiy the targets like class="target1" and class="target2".
I really dont understand why it only works for the first button ... what do i have to change to get the color changed through the corresponding button?
Thank you very much for your effort!!!
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$( "#dialog-link" ).click(function( event ) {
$(this).next(".start:first").css({"color": "red", "border": "2px solid red"});
});
});
</script>
</head>
<body>
<button id="dialog-link">click me1</button>
<div style="width:500px;" class="start">
Target1
</div>
<button id="dialog-link">click me2</button>
<div style="width:500px;" class="start">
Target2
</div>
</body>
</html>