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 3 years ago.
Improve this question
I have this function:
document.querySelector(".myDivClass");
Which accepts a div css class as parameter. How to make it accept a div id as parameter instead?
document.querySelector("#myDivId");
or
document.getElementById("myDivId");
As you can read there:
CSS Selectors, just replace dot with '#'. If this is your div:
<div id="abc" ></div>
then your selector would be document.querySelector("#abc");
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 months ago.
Improve this question
Can I use multiple different elements with inside siblings() in jquery?
and what would be the best practice in jquery to select sibling and can you also please explain why?
Yes. You can put in parentheses of the siblings the types of sibling elements you want, for example:
$("div").siblings("h2, p")
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();
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
How do I access the content of link to by JavaScript and jquery
<a href='http://example.com' id='my id'>content</a>
First of all the id cannot contain spaces.
Then with jQuery to access the content the value in the DOM you need to use the .html() after the selector.
Here is a working example :
http://jsfiddle.net/zuz660uk/
If on the other end you want the value of href then use .attr('href')
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
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.