Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery selector for attributes that does not begin with a string

Selector starting with [name^="value"] selects elements that have the specified attribute with a value beginning exactly with a given string.

Is there a negative of this like so:

[name!^="value"]

which selects elements that have the specified attribute with a value NOT beginning with a given string.

like image 664
user1024214 Avatar asked Nov 01 '11 17:11

user1024214


People also ask

Which selects elements that have the specified attribute with a value beginning exactly with a given string?

attributeStartsWith selector Description: Selects elements that have the specified attribute with a value beginning exactly with a given string.

What does $() return in jQuery?

$() does not return the jQuery function, (which is $ itself,) but returns a wrapped set, with all those helpful methods on it.

Does jQuery support selection based on attributes values?

jQuery [attribute|=value] Selector The [attribute|=value] selector selects each element with a specified attribute, with a value equal to a specified string (like "en") or starting with that string followed by a hyphen (like "en-us"). Tip: This selector is often used to handle language attributes.

What are the jQuery attributes and style methods?

jQuery attr(name, value) method is used to set the value of any standard attribute of the matched HTML element(s). We will use jQuery Selectors to match the desired element(s) and then we will apply attr(key, value) method to set the attribute value for the element.


2 Answers

$("div").not('[name^="value"]');
like image 101
Zoltan Toth Avatar answered Nov 09 '22 14:11

Zoltan Toth


Perhaps you can use the :not() selector: http://api.jquery.com/not-selector/

$('input').not('[name^="value"]')...;

Here's a jsfiddle using .not(): http://jsfiddle.net/hNhgf/

like image 20
Jasper Avatar answered Nov 09 '22 14:11

Jasper