0

How do we put agru inside function $('input[name=agru]')

 function changeBackground(agru){
      $('input[name=agru]').css('background','red');
}

$('input[name=agru]') isn't right. How do I escape? Thanks

1 Answer 1

2

Use

function addBorder(agru) {
    $('input[name=' + agru + ']').css('background', 'red');
}

Read How do I concatenate a string with a variable?

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

Comments

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.