Reputation: 1054
Sorry for basic... I expect some pro's will mark me down - again, however I have been struggling to see the error of my ways:
Unexpected token { is my error, and the code is:
<script>
$(document).ready(function {
$('people.img').click(function() {
$('.peopleSummary').addClass('hello');
})
});
Thanks!
Upvotes: -1
Views: 815
Reputation: 28845
There is no html element called people
, this is a incorrect selector
$('people.img')
Also to define a function you need ()
, otherwise you get also a syntax error
$(document).ready(function {
So try this, assuming your people
is a class
(otherwise use #
for a ID):
$(document).ready(function(){
$('.people.img').click(function() {
$('.peopleSummary').addClass('hello');
})
});
Upvotes: 2
Reputation: 67217
If people is a class
then try
$(document).ready(function(){
$('.people.img').click(function() {
$('.peopleSummary').addClass('hello');
})
});
If it is an id
try,
$(document).ready(function(){
$('#people.img').click(function() {
$('.peopleSummary').addClass('hello');
})
});
Upvotes: 1
Reputation: 388446
$(document).ready(function() {//<-- missig () after function
$('people.img').click(function () {
$('.peopleSummary').addClass('hello');
})
});
Upvotes: 3