Reputation: 2452
i have searched stackoverflow but i did not find any answers.
Please Check below html
<button type="button" class="nacnchor" value="1">hello</button>
<button type="button" class="nacnchor" value="2">hello</button>
<button type="button" class="nacnchor" value="3">hello</button>
I can change text of button based on class
$('button.nacnchor').text("REWRITE");
But i want to change the value based on attribute value , is ther anything like $('button.nacnchor,attr(value=1)')
:p .
Upvotes: 1
Views: 441
Reputation: 20765
When seeking how to use any given library it's always best to *R*ead *T*he *F*unny *M*anual which has an entire page dedicated to this.
...for example,
$("a[rel='nofollow']")
, will select<a href="example.html" rel="nofollow">Some text</a>
but not<a href="example.html" rel="nofollow foe">
Some text.Attribute values in selector expressions must follow the rules for W3C CSS selectors; in general, that means anything other than a valid identifier should be surrounded by quotation marks.
$('a[rel="nofollow self"]')
$("a[rel='nofollow self']")
$('a[rel=\'nofollow self\']')
$("a[rel=\"nofollow self\"]")
Upvotes: 1
Reputation: 56853
Attribute selectors are documented here: http://api.jquery.com/attribute-equals-selector/
$("button.nacnchor[value='1']").text("REWRITE");
Upvotes: 3