Skip to main content

Questions tagged [jquery-selectors]

Selectors can be used in jQuery to match a set of elements in a document. Most CSS selectors are implemented, as well as a set of custom ones.

jquery-selectors
-1 votes
2 answers
38 views

How can I select HTML elements which are rendered after DOM

I want to select OKBTN let main = document.querySelector("#main"); let okBtn = document.querySelector("#ok"); function myAlert(title,msg,icon){ let card = ""; ...
645 votes
10 answers
498k views

How to use a regular expression in a jQuery selector?

I am after documentation on using wildcard or regular expressions (not sure on the exact terminology) with a jQuery selector. I have looked for this myself but have been unable to find information on ...
0 votes
1 answer
28 views

How do I make a toggle Panel not be open by default? the toggle is made on JavaScript within the HTML

So I've got a page in which the user can find a "?" toggle to read information on how to use the page. However, whenever the page loads (or reloads/refreshes) the toggle panel opens up (as ...
32 votes
3 answers
51k views

Cheerio: How to select element by text content?

I have some HTML like this: <span id="cod">Code:</span> <span>12345</span> <span>Category:</span> <span>faucets</span> I want to fetch the category ...
1 vote
4 answers
110 views

css selector understanding

I am trying to select the first immediate child <p> element of <li> element that contains an immediate <ul> child. li>ul:parent>p:first-child is what I have tried, thinking ...
122 votes
21 answers
119k views

How can I get selector from jQuery object

$("*").click(function(){ $(this); // how can I get selector from $(this) ? }); Is there an easy way to get selector from $(this)? There is a way to select an element by its selector, but what ...
20 votes
7 answers
12k views

div:contains not a valid selector

I'm following this example and typed $( "div:contains('John')" ).css( "text-decoration", "underline" ); , but got an exception: VM23376:1 Uncaught DOMException: Failed to execute '$' on '...
20 votes
7 answers
10k views

What is the difference direct descendent (>) vs. descendant in jQuery selectors?

What's the difference between these two jQuery statements? They seem to do the same thing by getting all the children div tags. $("#mainblock div") $("#mainblock > div")
-1 votes
1 answer
136 views

How can I select an HTML element using jQuery where the attribute value contains spaces? [duplicate]

I need to select an HTML element using jQuery where the attribute value contains spaces. For example, I have an attribute data-compare which receives dynamic values from an API. Sometimes the data-...
0 votes
1 answer
28 views

Finding closest input in same cell multiple spans

I am having a hard time getting the closest input to the button clicked. Everything is on the same table cell. The button is inside a span and the input is inside 3 level span? Please see for ...
0 votes
2 answers
706 views

PAD JQuery - inner text in sibling of a parent

I am using Power Automate Desktop to get information from a dynamically generated website. The elements go very deep and they don't mostly have usable handles, so I need to use the inner text to ...
2284 votes
14 answers
1.1m views

How can I select an element with multiple classes in jQuery?

I want to select all the elements that have the two classes a and b. <element class="a b"> So, only the elements that have both classes. When I use $(".a, .b") it gives me the union, but I ...
102 votes
4 answers
133k views

jQuery - determine if input element is textbox or select list

How would I determine whether the element returned by an :input filter in jQuery is a textbox or select list? I want to have a different behavior for each ( textbox returns text value, select returns ...
16 votes
8 answers
403k views

If/else else if in Jquery for a condition

I am having a set of text fields where i am doing validation Say I am Having a field called "seats" this can accept value less than "99999".Meaning I should not able to enter the "99999" any thing ...
0 votes
4 answers
107 views

How can I select all elements of a class with a visible parent?

This is what I have but it doesn't seem to be working.. $('.parent-class:visible .my-class[state!="done"]') I want to select all .my-class elements that their .parent-class element is ...

15 30 50 per page
1
2 3 4 5
601