All Questions

721
votes
18answers
441488 views

Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQuery

Is there any way to select/manipulate CSS pseudo-elements such as ::before and ::after (and the old version with one semi-colon) using jQuery? For example, my stylesheet has the following rule: .spa...
141
votes
2answers
22807 views

Should all jquery events be bound to $(document)?

Where this is coming from When I first learned jQuery, I normally attached events like this: $('.my-widget a').click(function() { $(this).toggleClass('active'); }); After learning more about s...
1832
votes
27answers
1609182 views

Get selected text from a drop-down list (select box) using jQuery

How can I get a drop-down list selected text in jQuery, not using the selected value?
484
votes
9answers
340053 views

jQuery selector regular expressions

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...
2158
votes
29answers
1758072 views

How can I know which radio button is selected via jQuery?

I have two radio buttons and want to post the value of the selected one. How can I get the value with jQuery? I can get all of them like this: $("form :radio") How do I know which one is selected?...
1679
votes
9answers
686059 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 w...
128
votes
10answers
65459 views

Is there a case insensitive jQuery :contains selector?

Is there a case insensitive version of the :contains jQuery selector or should I do the work manually by looping over all elements and comparing their .text() to my string?
53
votes
1answers
10887 views

Why is my jQuery :not() selector not working in CSS?

I have this layout: <div id="sectors"> <h1>Sectors</h1> <div id="s7-1103" class="alpha"></div> <div id="s8-1104" class="alpha"></div> <div...
759
votes
8answers
831688 views

jQuery how to find an element based on a data-attribute value?

I've got the following scenario: var el = 'li'; and there are 5 <li>'s on the page each with a data-slide=number attribute (number being 1,2,3,4,5 respectively). I now need to find the curre...
62
votes
6answers
37887 views

Assign click handlers in for loop

I'm having several div's #mydiv1, #mydiv2, #mydiv3, ... and want to assign click handlers to them: $(document).ready(function(){ for(var i = 0; i < 20; i++) { $('#question' + i).click( funct...

Previous Next