Ze Carioca Silva
Ze Carioca Silva

Reputation: 443

Can someone tell me what is wrong with this jsfiddle

I have this jsfiddle made and I dont know what is wrong with the code:

http://jsfiddle.net/GYtNX/2/

Its not working as I wish and the final result is giving me this text "});//]]>" before the main text....

<h2>Shakespeare's Plays</h2>
<table>
<tr >
<td>As You Like It</td>
<td>Comedy</td>
<td></td>
</tr>
<tr>
<td>All's Well that Ends Well</td>
<td>Comedy</td>
<td>1601</td>

    </tr>
<tr>
<td>Hamlet</td>
<td>Tragedy</td>
<td>1604</td>
</tr>
<tr>
<td>Macbeth</td>
<td>Tragedy</td>
<td>1606</td>
</tr>
<tr>
<td>Romeo and Juliet</td>
<td>Tragedy</td>
<td>1595</td>
</tr>
<tr>
<td>Henry IV, Part I</td>
<td>History</td>
<td>1596</td>
</tr>
<tr>
<td>Henry V</td>
<td>History</td>
<td>1599</td>
</tr>
</table>

Then I have this script:

<script type="text/javascript">
$(document).ready(function () {
    $('td:contains(Henry)').parent().find('td:eq(1)')
    .addClass('highlight').end().find('td:eq(2)')
    .addClass('highlight')
});

And this css:

    tr {
background-color: #fff;
}
.alt {
background-color: #ccc;
}

.highlight {
background-color: #FCC;

I started jquery yesterday... Forgive me if the question is stupid.... All the code is on the jsfidle link... I just put here because stackovverflow demands so...

Upvotes: 0

Views: 65

Answers (2)

Sachin
Sachin

Reputation: 40970

As JS FIddle expects plain javascript code. you don't need to specify script tag so Remove <script type="text/javascript"></script> from your fiddle.

JS Fiddle

Upvotes: 1

Blender
Blender

Reputation: 298246

Your JSFiddle Script section shouldn't contain <script> tags. They're added for you automatically: http://jsfiddle.net/GYtNX/3/

Upvotes: 3

Related Questions