Q:

Finds even table rows, matching the first, third and so on (index 0, 2, 4 etc.) using jquery

0

Finds even table rows, matching the first, third and so on (index 0, 2, 4 etc.) using jquery

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Finds even table rows, matching the first, third  and so on.</title>
<style type="text/css">
button {
display: block;
margin: 20px 0 0 0;
}
</style>
</head>
<body>
<table border="1">
<tr><td>R1C1 Index-0</td><td>R1C2 Index-0</td></tr>
<tr><td>R2C1 Index-0</td><td>R2C2 Index-1</td></tr>
<tr><td>R3C1 Index-0</td><td>R3C2 Index-2</td></tr>
<tr><td>R4C1 Index-0</td><td>R4C2 Index-3</td></tr>
<tr><td>R5C1 Index-0</td><td>R5C2 Index-4</td></tr>
</table>
<button id="button1">Click to see the effect</button>
</body>
</html>

JavaScript Code :

$('#button1').click(function(){
$( "tr:even" ).css( "background-color", "orange" );
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now