Search code examples
jqueryjquery-selectors

Jquery Find a specific class with a specific attribute value


I currently have something like this in my code

<input class="parameterValueInput" trigger="@item.Name">

What I would like to do is to change content of an input that has a class name parameterValueInput and attribute called trigger with value "triggerValue"; I am not sure how to write a selector for that. any suggestions ?


Solution

  • You can try like this :

    $("input[class=parameterValueInput][trigger=triggerValue]").focus()
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
    <input class="parameterValueInput" trigger="triggerValdue">
    <input class="parameterValueInput" trigger="triggerValu2e">
    <input class="parameterValueInput" trigger="triggerValue">

    As , @mplungjan said in comment to use $("input.parameterValueInput[trigger=triggerValue]") if you have mutliple class else if only one class use above .