2

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 ?

0

1 Answer 1

2

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 .

Sign up to request clarification or add additional context in comments.

4 Comments

$("input.parameterValueInput[trigger=triggerValue]") is likely more safe
Your selector will fail on <input class="parameter parameterValueInput"
@mplungjan yes you are right :) Thank you for suggestion . I have added your suggestion in my answer .
ALWAYS use .class EVEN if you have one class, since it takes only a second to add a class and break the script. That can be added even from another part of the script so NEVER use class=someClass over .someClass

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.