i want to add css class to choice drop down filed using jquery below is code.

$("input[title='fieldname']").attr('class', 'form-control')

But somehow it is not working.

can anyone help me regarding this

  • Where you hvae Added "form-control" Class in sharepoint ? – Dipen Shah May 30 '16 at 10:55
  • it is in my css file – Rahul Dayal May 30 '16 at 10:56
  • Are you using <select> as drop down or <input> ? – Yayati May 30 '16 at 10:58
  • Might be it is SharePoint control @Yayati. – Dipen Shah May 30 '16 at 10:59
  • @Yayati i am using select as dropdown – Rahul Dayal May 30 '16 at 10:59

You are using input instead of select in your script. Try following script:

$("select[title='fieldname']").attr('class', 'form-control')
| improve this answer | |
  • addClass('form-control') is cleaner than adding the class attribute yourself. – user2536 May 30 '16 at 15:20
  • Yes, I agree. addClass('form-control') method add another class to the element wherease .attr('class', 'form-control') will replace any class attached to the element with the specified one. – Yayati May 31 '16 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.