jQuery selectors with variables

Edit: Based on your comment below, you would use this: $(‘#one img.’+id) In your question you have a space between img and the .class, I’ve simply removed that so you get img.className or img.’+className With the introduction of template literals in ECMAScript 2015, you can also do $(`#one img.${id}`)

Access the css “:after” selector with jQuery [duplicate]

You can’t manipulate :after, because it’s not technically part of the DOM and therefore is inaccessible by any JavaScript. But you can add a new class with a new :after specified. CSS: .pageMenu .active.changed:after { /* this selector is more specific, so it takes precedence over the other :after */ border-top-width: 22px; border-left-width: 22px; border-right-width: … Read more

Is there a case insensitive jQuery :contains selector?

What I ended up doing for jQuery 1.2 is : jQuery.extend( jQuery.expr[‘:’], { Contains : “jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0” }); This will extend jquery to have a :Contains selector that is case insensitive, the :contains selector remains unchanged. Edit: For jQuery 1.3 (thanks @user95227) and later you need jQuery.expr[‘:’].Contains = function(a,i,m){ return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0; }; Edit: Apparently accessing the … Read more