Home › Forums › JavaScript › What’s wrong with my jQuery code?
- This topic is empty.
-
AuthorPosts
-
February 21, 2012 at 5:33 am #36742schartParticipant
$(document).ready(function(){
$('a[href="#"]').click(function(){
event.preventDefault();
});
$("#infol").click(function(){
$("#wall").slideUp();
$("#contact").slideUp();
$("#info").slideToggle();
});
$("#walll").click(function(){
$("#info").slideUp();
$("#contact").slideUp();
$("#wall").slideToggle();
});
$("#contl").click(function(){
$("#info").slideUp();
$("#wall").slideUp();
$("#contact").slideToggle();
});
});Also, jQuery is loaded, it’s just this part that doesn’t work on Firefox or IE, it works on Safari and Chrome (webkit) though. Any suggestions?
February 21, 2012 at 5:37 am #97084sliver37MemberTry
$('a[href="#"]').click(function(event){
event.preventDefault();
});
February 21, 2012 at 5:41 am #97086jamygoldenMember@silver37 is right, that should work.
You are calling a variable that doesn’t exist.
February 21, 2012 at 5:50 am #97089jamygoldenMemberTry this:
$(document).ready(function(){
$('a[href="#"]').click(function(e){
e.preventDefault();
});
$("#infol").click(function(){
$("#wall").slideUp();
$("#contact").slideUp();
$("#info").slideToggle();
});
$("#walll").click(function(){
$("#info").slideUp();
$("#contact").slideUp();
$("#wall").slideToggle();
});
$("#contl").click(function(){
$("#info").slideUp();
$("#wall").slideUp();
$("#contact").slideToggle();
});
});February 21, 2012 at 6:46 am #97093jamygoldenMemberDon’t you have an html example? What do you mean by ‘its not working’. How do you know it’s not working?
Create a little test on jsfiddle and we’ll be able to help you quickly/easily.
P.S. If you’re using the js I added above, then the JS isn’t ‘breaking’. The syntax is fine. If you slideUp something that is already up, nothing will happen.
February 21, 2012 at 8:17 am #97097jamygoldenMemberWorks fine for me in Chrome and Firefox 10.0.2.
February 21, 2012 at 8:30 am #97099jamygoldenMemberDo you have firebug?
Open firebug, go to the console tab. Refresh the page. There should be an error, what does it say?
February 22, 2012 at 7:47 am #97179trav5567MemberI know im going at this the wrong way which is why i am asking for some help, I am wanting my script to work so that when the contact div is down and you click anywhere else on the page the contact div will animate back up. If you have any suggestions for making it smoother that would be great too:)
Thanks!
Here is a link for what i am trying to do
$(document).ready(function() {
$("a.contact-btn").toggle(
function () {
$("#contact").animate( {"top": "0"}, 900, "linear" );
},
function () {
$("#contact").animate( {"top": "-400px"}, 900, "linear" );
});
$('body').bind('click', function() {
var position = $('#contact').css('marginTop');
if ( position != '-400px') {
$("#contact").animate( {"top": "-400px"}, 900, "linear" );
}
});
});
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.