Remove div class if display:none [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I would like to know if there is a way to remove a class when that class is marked with display: none;. Basically, I would like to prevent it from loading.
Is it possible to do it using JQuery?
Thanks in advance!

$('.class-you-want-to-remove:hidden').removeClass('class-you-want-to-remove');
https://api.jquery.com/hidden-selector/

You can use hide() method in jQuery to hide the blocks under that class.
$(".classname").hide();
Similarly you use show() method to show the blocks under that class.
$(".classname").show();

Related

Un-applying certain tags in Bootstrap [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Can anyone help me a bit?
I'm using bootstrap, and I do not want bootstrap to change a certain tag (by id,class or element). How can I change the behaviour?
Thanks in advance.
One of these could be added to your main css file. Using the class browser-default would then remove all styles from an element.
.browser-default {
all: initial;
}
.browser-default {
all: initial !important;
}

jQuery, reuse method for many divs [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a CoffeeScript code that looks like this:
if $('#user_address_attributes_country').val() == ""
$('#user_address_attributes_country').val("PL")
Now I want to do the same thing for a few divs but without repetitions.
How can it be done by jQuery?
The reason you can't apply it multiple times is because your trying to apply it to an element which has an id. They are unique. Use classes and do this instead:
if ($('.user_address_attributes_country').val("")) {
$('.user_address_attributes_country').val("PL");
}
Simple demo: JsFiddle

Using CSS in JS [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to change CSS elements depending on situations used in javascript.
an example I had tried was:
if ('image'=="clicked")
{blahblahblah}
'image' would be my div id or div tag in CSS.
I know in Jquery I can use $('#image').click, but I don't think it Jquery will be good for my situation.
Consider document.querySelector. It's powerful, accepting any valid CSS selector. You can even start from another element, such as myElement.querySelector, to only get children of that element that match the selector. Very useful!
Just be aware that IE7 and below do not support this function.
Assuming your id as image
document.getElementById('image').onclick = function() {
alert("button was clicked");
}​;​

Change the divs style in parent of parent using jquery [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to change the div's style which is located in the parent of a parent. I am able to access them via DOM, but how can I change its CSS style using JQuery?
Selection code:
window.parent.parent.parent.document.getElementsByTagName('code').
I would love to only change a div that doesn't have display:none already set, but I really don't care if we change only one, or all of them.
You can always use the context parameter on $( selector [, context ] )
$("[name=code]",parent.parent.parent.document).css('display','none');
If you want to only change the one that are visible you can use the is function in JQuery in order to filter:
$("[name=code]",parent.parent.parent.document).is(':visible').css('display','none');
JQuery page: https://api.jquery.com/jquery/

jQuery slideUp slideDown help, it's slideToggle [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
If i click a division it will slidUp and if i click that division again it will slideDown.
How can i do this ?
$("#id_color_tags").click(function(){
$("#rightsidefive").slideToggle();
})
Tried that but that didn't work.
Put an alert in the click event, are you getting to the function?
Are the names right. asp.net can alter names so maybe select on a class name instead. So <div class="thisclass"> and the selector then becomes ".thisclass"
Same applies for the #rightsidediv
Failing that, post some HTML so we can see.

Categories