Home › Forums › JavaScript › my basic jquery not working
- This topic is empty.
-
AuthorPosts
-
December 19, 2012 at 10:35 pm #41469
taragrg
Member
Hi friends click me to hide
this is the code and its not working i am using the CDN instead of local jquery and why is it not working thanks
December 19, 2012 at 10:44 pm #118202kevin11189
ParticipantIt’s working for me….
December 19, 2012 at 10:54 pm #118204taragrg
Memberyea its working in your framework kevin11189 but its not working in my browser dont know why
December 19, 2012 at 11:11 pm #118206kevin11189
ParticipantAlright, this might be a little over my head, but I copied your text and made a little local site to text it out with 1.8.3.min.js and I noticed that there was some weird unseen characters in the source that isn’t in the code. I’m no pro when it comes to UTF stuff and line ending, but check your source in the browser and make sure there isn’t anything weird in your script that you don’t see in your editor.
December 19, 2012 at 11:13 pm #118207kevin11189
ParticipantBut yeah, this works perfectly fine for me with 1.8.3.min.js
Hello world!
December 19, 2012 at 11:15 pm #118208kevin11189
ParticipantErg, the code block didn’t work, but yeah, let me know what your source shows. Can you link to the actual site?
December 20, 2012 at 2:00 am #118218JohnMotylJr
Participant@taragrg : Remember that you need to close off your javascript resources with an ending script tag.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
December 20, 2012 at 3:41 am #118226alfiebesin
Participant@JohnMotylJr is right. You need to close your script tag there.
Like this:<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
December 20, 2012 at 3:45 am #118227alfiebesin
Participant@JohnMotylJr is right. You need to close your script tag there.
Like this:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
December 20, 2012 at 6:54 am #118239SgtLegend
MemberJust a couple of nitpicks, the below is the recommended way of writing jQuery.
// This is the shorthand way of writing $(document).ready()
$(function() {
// Since jQuery 1.5 its now recommend you use the on() method
$(‘p’).on(‘click’, function() {
// Always use “this” as it referrers to the current element context not every p element
$(this).hide();
});
});December 20, 2012 at 7:36 am #118245taragrg
Memberyea i have ended the **script on the next line** ,I know the code is correct but why is this not working am not using IE i know it sucks
December 20, 2012 at 2:26 pm #118301JohnMotylJr
Participant@taragrg : For some reason i believe it may be some kind of syntax error. I suggest you either: A.) Upload your page to a server and post the link for us to see. B.) Copy ALL of your code and go to this website to convert characters. Once converted, come back to this forum, paste your new code, and wrap said new code inside of pre and code tags.
The reason for this is so we can see exactly what you are doing because even though @SgtLegend have some great advice and @kevin11189 even gave you a working example, i believe you are missing something.
Better yet, validate your html with the W3C tool.
December 20, 2012 at 3:07 pm #118306joberndtsson
MemberYes it’s a syntax error I believe Too.
John B
December 20, 2012 at 3:11 pm #118307joberndtsson
MemberDecember 21, 2012 at 3:43 am #118377taragrg
MemberThanks to all its working fine Thanks thanks thansk :) it was just a syntax error thanks JohnMotylJr
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.