Most voted "selectors" questions
A CSS selector is a statement in a format that "matches" all elements that follow that format in the document tree.
Learn more…39 questions
Sort by count of
-
37
votes1
answer3274
viewsWhich CSS selector has priority?
I have the following code HTML and CSS: #element p{color:blue;} .element p{color:red;} div p{color:pink;} div.element p{color:yellow;} div[name="element"] p{color:purple;} div…
-
19
votes3
answers910
viewsHow to use $.on in pure Javascript: "$(...). on(event, selector, function)"?
It is as follows, in jQuery we have the on, any element <a> with class test and without the class foo will trigger the function when clicked, even if you create the element later the event is…
-
11
votes1
answer2651
viewsWhat does the CSS selector :first-Child and :last-Child mean?
I have a code using jQuery that was based on CSS selectors :first-child and :last-child (and that worked for a long time), to get the first input and the last input within a group containing input +…
-
10
votes5
answers18134
viewsUsing jQuery, how to select elements with two CSS classes
I have a div that uses two CSS classes. Here is the HTML : <div class="box1"></div> <div class="box1 destaque"></div> <div class="box2"></div> <div class="box2…
-
9
votes3
answers14251
viewsSelect elements containing a particular "date" attribute
On the page there are several elements with attributes data. To avoid going around adding CSS classes to the elements, making page code denser, I would like to select elements by attribute name…
-
9
votes2
answers991
viewsHow to select element in the lowest hierarchical level?
I need to select the ul parent of the element li that is being clicked. But as a li is inside the other javascript understands that I am clicking on li and in all li parents. <ul…
-
7
votes1
answer118
viewsHow to use the first-Child selector for a specific class
Hello, I have several Ivs and some of them have a 'test' class, I would like the first-Hild selector to highlight only the first DIV that has the 'test' class, but it only works if the 'test' class…
-
5
votes3
answers139
viewsDifference between attr=val, attr="val" and attr='val' in Javascript?
There is some difference in using the selector in the following ways, or one that is "correct"? [name="val"] [name='val'] [name=val]
-
4
votes2
answers133
viewsWhen using div+selector in CSS
Whenever I am developing the front-end of some site, I put the name of the selector, for example .seletor1, .seletor2 and so on. Recently I had to change the classes of a plugin I downloaded, and I…
-
4
votes1
answer137
viewsPerformance CSS (CSSOM and selectors)
Considering the assembly of CSSOM by the browser and parser (read) given right to left. I would like to play a question, because I was writing a css in a project and always have with me for…
-
4
votes2
answers189
viewsWhat is the inverse of :Visible in jQuery?
The Selector :visible jQuery is used to search for an element when it is visible. Example: $(this).find('li:visible').addClass('color-red'); However, when trying to search for invisible elements, we…
-
4
votes2
answers861
viewsWhat is the difference between :Nth-Child and :Nth-of-type?
Most of the time I use the :Nth-of-type but I didn’t understand exactly the difference between the two, someone can explain?
-
4
votes1
answer48
viewsHow to make a parent <ul> element have the width of your children’s total <li>?
Have a div that dynamically displays a series of items grouped into a horizontal list. The parent element of this list has a maximum width defined in my CSS. It is possible to make the specific…
-
3
votes1
answer1084
viewsWhat is ":eq(0)" for and how?
I was watching a tutorial on slider for jQuery, and in a part of the code, in which the goal was to return to the first image, the author of the code did it in a way that I do not know, and also did…
-
3
votes3
answers127
viewsjQuery, do not select 'Child' from the element
I have this code that makes of a kind of fancybox, it works well but I wish that the click in the image did not make disappear the '#overlayFancy', it was good that only the click out of the image…
-
3
votes1
answer384
viewsConcatenate in loop with jQuery
I need to concatenate with jQuery all input values that have classes that start with "item_". I’m using the function below but it didn’t work. $(document).ready(function() {…
-
3
votes2
answers93
viewsDo you really need to specify the HTML element before the class in the selector of a CSS rule?
I don’t know if that’s true for everyone, but the only element I’m interested in is <div>. For example: div.classe1 { /*...*/ } .clase1 { /*...*/ } What is the difference between the two…
-
3
votes1
answer73
viewsWhy do selectors with prefixes in the same rule not work?
For example if I do this to let the element that is in fullscreen with height and width equal 100% it does not work: :fullscreen, :full-screen, :-webkit-full-screen, :-moz-full-screen,…
-
2
votes3
answers301
viewsCss selector syntax to delete <td> element with jQuery
Some way to use jquery and selectors in a way similar to this? $("#tabela td").empty(); I need to delete only the lines tr containing td of a table like this, but not the rows tr which contain…
-
2
votes1
answer292
viewsTabulation via Jquery
I have a field with the class "codigoBarra" where will be used barcode reader to fill it, at the end of reading with the reader it generates an n, I already managed to capture this and treat,…
-
2
votes2
answers783
viewsCSS - How to select the last sibling?
I have the following HTML structure: <form action="" id="form-contato"> <label for="nome">Nome</label> <input type="text" name="nome" id="nome" placeholder="Nome"/> <label…
-
2
votes1
answer2250
viewsTransition into elements using :Hover:after
How can I apply a transition, for example in a background:linear-gradient(to top, rgba(0,0,0,.6) 0%, rgba(0,0,0,0) 40%) without hover and background:linear-gradient(to top, rgba(0,0,0,.8) 0%,…
-
2
votes1
answer46
viewsJquery does not take input value
$(document).on('click','#submit',function(){ console.log($('#prescricao[qtd][1]').val()); }); <script…
-
2
votes2
answers44
viewsSelector lt() does not work
In my jQuery selector experiments I came across something that I don’t know is my mistake or is a natural limitation of jQuery. I have 10 Ivs with classes .dado. Each, when clicked, changes the…
-
2
votes2
answers40
viewsHow to apply a function with "foreach", using a set of pre-selected items by the Jquery style selector?
I do not know if I could be clear in the title, and so I will illustrate. In jQuery, we could do something like this to make all H2 green: $('h2').css('color','green') I’m trying to get rid of…
-
1
votes1
answer548
viewsSelect only the first children of a parent element
I have the following appointment: <div class="step-content"> <div id="step-1"> <h1>step 1</h1> <h1>step 1</h1> </div> <div id="step-2"> <h1>step…
-
1
votes1
answer83
viewsSelect input with id != value
a selector like this: $('#minhaDiv input[id!="meuId1"]'); is well comun. I wonder if it is possible to do something like: $('#minhaDiv input[id!="meuId1" && id!="meuId8"]'); Thank you.…
-
1
votes1
answer187
viewsCSS selectors (H1 - H6 applying after p)
I’m in doubt of applying some effects to css. I tried with the following css selectors: h1+p, h2+p, h3+p, h4+p, h5+p, h6+p { margin: 0 0 0.75em 0; } h1~p, h2~p, h3~p, h4~p, h5~p, h6~p { margin: 0 0…
-
1
votes2
answers28
viewsCSS Selector - Run a loop from a particular loop item
Good morning. Let’s say I have a table with 100 rows, the more I’d like my each (Jquery) to start from line 15. Which Css selector should I use? Or Jquery has some resource for this? Thanks to all…
-
1
votes1
answer1108
viewsCSS selector to modify TAG before or after inside the div
I’m in doubt when applying some styles to css. I wish to modify a tag using a div within it: header { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex;…
-
1
votes1
answer29
viewsjQuery selector does not find itself
I was assembling a feature that aimed to find others selects of equal value, when I came across this situation : jQuery('select[name="group2"]').val('emissao');…
-
0
votes6
answers2500
viewsHover on DIV1 change DIV2 with CSS
If I have a #div1 and a #div2, and they are brothers, I know I can use the dial ~ to stylize the #div2 as follows: #div1:hover ~ #div2 { /* regras */ } Is there an equivalent selector to style the…
-
0
votes1
answer330
viewsput variable in jquery selector
I researched other similar questions, but their answers didn’t help me because, the selector I’m using is different. want to catch a tr in a tbody of a table, using the selector nth-child(n) but in…
-
0
votes1
answer28
viewsSelecting disabled elements
I need to differentiate the view from a select box where there is an element selected by default, but it cannot be selected by the user (as if it were a placeholder of a normal input), but I want to…
-
0
votes0
answers73
viewsQuery selector /3a
I’m making js of htmls complexes that were not structured by me. To facilitate use of Firebux or Chrome Developer to copy the ready selector. They return me this selector: #dadosCadastrais\3a…
-
0
votes3
answers164
viewsI can’t find the button with the querySelector
Hi, I’m trying to find a button by Document.querySelector but I’m not getting it. I tried looking for it with the command: document.querySelector("button.tabindex[class='btn btn-inverse btn-large…
-
0
votes1
answer75
viewschanging the css of the pseudo classes of elements with jquery is possible?
I’m doing some tests with jquery and, came to me the following question: It is possible to manipulate the pseudo class elements css with the jquery? $('#login_1').click(function(event){…
-
0
votes1
answer43
viewsHow to use special characters to select an element using jQuery?
I need to check if a input type=radio was checked with jQuery to pass to the next step of the form. My function for this was already working, but I needed to transform the name of checkbox in array…
-
-2
votes1
answer26
viewsPick element by css selector
I have a div where I want to take it by function document.querySelector but I can’t The div: <div class=" f:.9 m-b:.4 m-t:.5 d:i-b ">Conteúdo</div> I tried to make…