0

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

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

1 Answer 1

0

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

$("select[title='fieldname']").attr('class', 'form-control')
2
  • addClass('form-control') is cleaner than adding the class attribute yourself.
    – user2536
    Commented May 30, 2016 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
    Commented May 31, 2016 at 5:31

Your Answer

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

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