jquery click function addclass
up vote
0
down vote
favorite
I've got a strange problem where "most" of my rules work inside a click function, but one won't
$(".fadeOut input").click(function() {
$(".nooverlay").addClass("overlayon");
$(".searchBar").addClass("fadeIn");
$(".searchBar").removeClass("fadeOut")
});
addClass("overlayon") won't work ?!?!?
fadeIn works
fadeOut works
the entire js can be seen here:
https://github.com/TerminalAddict/ta.com-website/blob/master/assets/js/ta.js
I'm using to yui-compressor to compress, then create one big bundle (bundle.js)
no errors in console, and if I paste this function into the console it works fine.
Live demo: https://terminaladdict.com
jquery click
New contributor
add a comment |
up vote
0
down vote
favorite
I've got a strange problem where "most" of my rules work inside a click function, but one won't
$(".fadeOut input").click(function() {
$(".nooverlay").addClass("overlayon");
$(".searchBar").addClass("fadeIn");
$(".searchBar").removeClass("fadeOut")
});
addClass("overlayon") won't work ?!?!?
fadeIn works
fadeOut works
the entire js can be seen here:
https://github.com/TerminalAddict/ta.com-website/blob/master/assets/js/ta.js
I'm using to yui-compressor to compress, then create one big bundle (bundle.js)
no errors in console, and if I paste this function into the console it works fine.
Live demo: https://terminaladdict.com
jquery click
New contributor
I've also tried:$("fadeOut").on("click", "input", function(a) { a.preventDefault(); $(".nooverlay").addClass("overlayon"); $(".searchBar").addClass("fadeIn"); $(".searchBar").removeClass("fadeOut") });
– TerminalAddict
Nov 5 at 2:49
What's the purpose of the classesnooverlay
andoverlayon
?
– D. Smania
Nov 5 at 3:05
overlayon to create a 100% height 100% width overlay with with opaque background, that is clickable (to close the searchbar) nooverlay, because I though jquery was getting confused by not having an original class
– TerminalAddict
Nov 5 at 3:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I've got a strange problem where "most" of my rules work inside a click function, but one won't
$(".fadeOut input").click(function() {
$(".nooverlay").addClass("overlayon");
$(".searchBar").addClass("fadeIn");
$(".searchBar").removeClass("fadeOut")
});
addClass("overlayon") won't work ?!?!?
fadeIn works
fadeOut works
the entire js can be seen here:
https://github.com/TerminalAddict/ta.com-website/blob/master/assets/js/ta.js
I'm using to yui-compressor to compress, then create one big bundle (bundle.js)
no errors in console, and if I paste this function into the console it works fine.
Live demo: https://terminaladdict.com
jquery click
New contributor
I've got a strange problem where "most" of my rules work inside a click function, but one won't
$(".fadeOut input").click(function() {
$(".nooverlay").addClass("overlayon");
$(".searchBar").addClass("fadeIn");
$(".searchBar").removeClass("fadeOut")
});
addClass("overlayon") won't work ?!?!?
fadeIn works
fadeOut works
the entire js can be seen here:
https://github.com/TerminalAddict/ta.com-website/blob/master/assets/js/ta.js
I'm using to yui-compressor to compress, then create one big bundle (bundle.js)
no errors in console, and if I paste this function into the console it works fine.
Live demo: https://terminaladdict.com
jquery click
jquery click
New contributor
New contributor
New contributor
asked Nov 5 at 2:34
TerminalAddict
83
83
New contributor
New contributor
I've also tried:$("fadeOut").on("click", "input", function(a) { a.preventDefault(); $(".nooverlay").addClass("overlayon"); $(".searchBar").addClass("fadeIn"); $(".searchBar").removeClass("fadeOut") });
– TerminalAddict
Nov 5 at 2:49
What's the purpose of the classesnooverlay
andoverlayon
?
– D. Smania
Nov 5 at 3:05
overlayon to create a 100% height 100% width overlay with with opaque background, that is clickable (to close the searchbar) nooverlay, because I though jquery was getting confused by not having an original class
– TerminalAddict
Nov 5 at 3:20
add a comment |
I've also tried:$("fadeOut").on("click", "input", function(a) { a.preventDefault(); $(".nooverlay").addClass("overlayon"); $(".searchBar").addClass("fadeIn"); $(".searchBar").removeClass("fadeOut") });
– TerminalAddict
Nov 5 at 2:49
What's the purpose of the classesnooverlay
andoverlayon
?
– D. Smania
Nov 5 at 3:05
overlayon to create a 100% height 100% width overlay with with opaque background, that is clickable (to close the searchbar) nooverlay, because I though jquery was getting confused by not having an original class
– TerminalAddict
Nov 5 at 3:20
I've also tried:
$("fadeOut").on("click", "input", function(a) { a.preventDefault(); $(".nooverlay").addClass("overlayon"); $(".searchBar").addClass("fadeIn"); $(".searchBar").removeClass("fadeOut") });
– TerminalAddict
Nov 5 at 2:49
I've also tried:
$("fadeOut").on("click", "input", function(a) { a.preventDefault(); $(".nooverlay").addClass("overlayon"); $(".searchBar").addClass("fadeIn"); $(".searchBar").removeClass("fadeOut") });
– TerminalAddict
Nov 5 at 2:49
What's the purpose of the classes
nooverlay
and overlayon
?– D. Smania
Nov 5 at 3:05
What's the purpose of the classes
nooverlay
and overlayon
?– D. Smania
Nov 5 at 3:05
overlayon to create a 100% height 100% width overlay with with opaque background, that is clickable (to close the searchbar) nooverlay, because I though jquery was getting confused by not having an original class
– TerminalAddict
Nov 5 at 3:20
overlayon to create a 100% height 100% width overlay with with opaque background, that is clickable (to close the searchbar) nooverlay, because I though jquery was getting confused by not having an original class
– TerminalAddict
Nov 5 at 3:20
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
As input box you are target is having an ID and Div element where you are trying to add class is also have an ID. ID's are unique and I think you can use below piece of code. That i also tried executing on console window and seems to be working.
$("#query").click(function(e){
event.preventDefault();
if($('#query').parents('.fadeOut').length>0){
$('#overlay').addClass('overlayon');
$('.searchBar').addClass('fadeIn');
$('.searchBar').removeClass('fadeOut');
}
});
As We have Black Background to appear only in case of .fadeout class So I have added below code in jquery code above to check if parent of Query Textbox has that class. It seems to be working fine.
if($('#query').parents('.fadeOut').length>0){
makes no difference sorry
– TerminalAddict
Nov 5 at 3:35
as you also have id to that element can you try with id instead of class like $('#overlay').addclass('overlayon');
– Heemanshu Bhalla
Nov 5 at 3:42
I need to target$('fadeOut #query)
as I don't want this to run when the searchBar is fadeIn .. let me try
– TerminalAddict
Nov 5 at 4:12
@TerminalAddict I have updated above code it seems to be working fine on console for all 3 rules. code you gave in question was not working on console also.
– Heemanshu Bhalla
Nov 5 at 4:14
1
legend !!! that did the trick ! Thanks so much
– TerminalAddict
Nov 5 at 4:28
|
show 1 more comment
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
As input box you are target is having an ID and Div element where you are trying to add class is also have an ID. ID's are unique and I think you can use below piece of code. That i also tried executing on console window and seems to be working.
$("#query").click(function(e){
event.preventDefault();
if($('#query').parents('.fadeOut').length>0){
$('#overlay').addClass('overlayon');
$('.searchBar').addClass('fadeIn');
$('.searchBar').removeClass('fadeOut');
}
});
As We have Black Background to appear only in case of .fadeout class So I have added below code in jquery code above to check if parent of Query Textbox has that class. It seems to be working fine.
if($('#query').parents('.fadeOut').length>0){
makes no difference sorry
– TerminalAddict
Nov 5 at 3:35
as you also have id to that element can you try with id instead of class like $('#overlay').addclass('overlayon');
– Heemanshu Bhalla
Nov 5 at 3:42
I need to target$('fadeOut #query)
as I don't want this to run when the searchBar is fadeIn .. let me try
– TerminalAddict
Nov 5 at 4:12
@TerminalAddict I have updated above code it seems to be working fine on console for all 3 rules. code you gave in question was not working on console also.
– Heemanshu Bhalla
Nov 5 at 4:14
1
legend !!! that did the trick ! Thanks so much
– TerminalAddict
Nov 5 at 4:28
|
show 1 more comment
up vote
0
down vote
accepted
As input box you are target is having an ID and Div element where you are trying to add class is also have an ID. ID's are unique and I think you can use below piece of code. That i also tried executing on console window and seems to be working.
$("#query").click(function(e){
event.preventDefault();
if($('#query').parents('.fadeOut').length>0){
$('#overlay').addClass('overlayon');
$('.searchBar').addClass('fadeIn');
$('.searchBar').removeClass('fadeOut');
}
});
As We have Black Background to appear only in case of .fadeout class So I have added below code in jquery code above to check if parent of Query Textbox has that class. It seems to be working fine.
if($('#query').parents('.fadeOut').length>0){
makes no difference sorry
– TerminalAddict
Nov 5 at 3:35
as you also have id to that element can you try with id instead of class like $('#overlay').addclass('overlayon');
– Heemanshu Bhalla
Nov 5 at 3:42
I need to target$('fadeOut #query)
as I don't want this to run when the searchBar is fadeIn .. let me try
– TerminalAddict
Nov 5 at 4:12
@TerminalAddict I have updated above code it seems to be working fine on console for all 3 rules. code you gave in question was not working on console also.
– Heemanshu Bhalla
Nov 5 at 4:14
1
legend !!! that did the trick ! Thanks so much
– TerminalAddict
Nov 5 at 4:28
|
show 1 more comment
up vote
0
down vote
accepted
up vote
0
down vote
accepted
As input box you are target is having an ID and Div element where you are trying to add class is also have an ID. ID's are unique and I think you can use below piece of code. That i also tried executing on console window and seems to be working.
$("#query").click(function(e){
event.preventDefault();
if($('#query').parents('.fadeOut').length>0){
$('#overlay').addClass('overlayon');
$('.searchBar').addClass('fadeIn');
$('.searchBar').removeClass('fadeOut');
}
});
As We have Black Background to appear only in case of .fadeout class So I have added below code in jquery code above to check if parent of Query Textbox has that class. It seems to be working fine.
if($('#query').parents('.fadeOut').length>0){
As input box you are target is having an ID and Div element where you are trying to add class is also have an ID. ID's are unique and I think you can use below piece of code. That i also tried executing on console window and seems to be working.
$("#query").click(function(e){
event.preventDefault();
if($('#query').parents('.fadeOut').length>0){
$('#overlay').addClass('overlayon');
$('.searchBar').addClass('fadeIn');
$('.searchBar').removeClass('fadeOut');
}
});
As We have Black Background to appear only in case of .fadeout class So I have added below code in jquery code above to check if parent of Query Textbox has that class. It seems to be working fine.
if($('#query').parents('.fadeOut').length>0){
edited Nov 5 at 4:13
answered Nov 5 at 2:58
Heemanshu Bhalla
1,9351127
1,9351127
makes no difference sorry
– TerminalAddict
Nov 5 at 3:35
as you also have id to that element can you try with id instead of class like $('#overlay').addclass('overlayon');
– Heemanshu Bhalla
Nov 5 at 3:42
I need to target$('fadeOut #query)
as I don't want this to run when the searchBar is fadeIn .. let me try
– TerminalAddict
Nov 5 at 4:12
@TerminalAddict I have updated above code it seems to be working fine on console for all 3 rules. code you gave in question was not working on console also.
– Heemanshu Bhalla
Nov 5 at 4:14
1
legend !!! that did the trick ! Thanks so much
– TerminalAddict
Nov 5 at 4:28
|
show 1 more comment
makes no difference sorry
– TerminalAddict
Nov 5 at 3:35
as you also have id to that element can you try with id instead of class like $('#overlay').addclass('overlayon');
– Heemanshu Bhalla
Nov 5 at 3:42
I need to target$('fadeOut #query)
as I don't want this to run when the searchBar is fadeIn .. let me try
– TerminalAddict
Nov 5 at 4:12
@TerminalAddict I have updated above code it seems to be working fine on console for all 3 rules. code you gave in question was not working on console also.
– Heemanshu Bhalla
Nov 5 at 4:14
1
legend !!! that did the trick ! Thanks so much
– TerminalAddict
Nov 5 at 4:28
makes no difference sorry
– TerminalAddict
Nov 5 at 3:35
makes no difference sorry
– TerminalAddict
Nov 5 at 3:35
as you also have id to that element can you try with id instead of class like $('#overlay').addclass('overlayon');
– Heemanshu Bhalla
Nov 5 at 3:42
as you also have id to that element can you try with id instead of class like $('#overlay').addclass('overlayon');
– Heemanshu Bhalla
Nov 5 at 3:42
I need to target
$('fadeOut #query)
as I don't want this to run when the searchBar is fadeIn .. let me try– TerminalAddict
Nov 5 at 4:12
I need to target
$('fadeOut #query)
as I don't want this to run when the searchBar is fadeIn .. let me try– TerminalAddict
Nov 5 at 4:12
@TerminalAddict I have updated above code it seems to be working fine on console for all 3 rules. code you gave in question was not working on console also.
– Heemanshu Bhalla
Nov 5 at 4:14
@TerminalAddict I have updated above code it seems to be working fine on console for all 3 rules. code you gave in question was not working on console also.
– Heemanshu Bhalla
Nov 5 at 4:14
1
1
legend !!! that did the trick ! Thanks so much
– TerminalAddict
Nov 5 at 4:28
legend !!! that did the trick ! Thanks so much
– TerminalAddict
Nov 5 at 4:28
|
show 1 more comment
TerminalAddict is a new contributor. Be nice, and check out our Code of Conduct.
TerminalAddict is a new contributor. Be nice, and check out our Code of Conduct.
TerminalAddict is a new contributor. Be nice, and check out our Code of Conduct.
TerminalAddict is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147596%2fjquery-click-function-addclass%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
I've also tried:
$("fadeOut").on("click", "input", function(a) { a.preventDefault(); $(".nooverlay").addClass("overlayon"); $(".searchBar").addClass("fadeIn"); $(".searchBar").removeClass("fadeOut") });
– TerminalAddict
Nov 5 at 2:49
What's the purpose of the classes
nooverlay
andoverlayon
?– D. Smania
Nov 5 at 3:05
overlayon to create a 100% height 100% width overlay with with opaque background, that is clickable (to close the searchbar) nooverlay, because I though jquery was getting confused by not having an original class
– TerminalAddict
Nov 5 at 3:20