Form text boxes elements | XM Community
Skip to main content
Question

Form text boxes elements


I have 4 text boxes in a form, I apply jQuery as shown below.
jQuery("#"+this.questionId+" input[type='text']:first-child").css("max-width","30%").after(" cm");
jQuery("#"+this.questionId+" input[type='text']:nth-child(2)").css("max-width","30%").after(" kg");
jQuery("#"+this.questionId+" input[type='text']:nth-child(3)").css("max-width","30%").after(" cm");
jQuery("#"+this.questionId+" input[type='text']:last-child").css("max-width","30%").after(" cm");

However, the outputs are the same for the text "cm" after each text box. Weight item should be in "kg".
image.pngWelcome suggestions.



2 replies

  • Author
  • 10 replies
  • February 8, 2021

I fixed as follows
jQuery("#"+this.questionId+" input[type='text']:first").css("max-width","30%").after(" cm");
jQuery("#"+this.questionId+" input[type='text']:eq(1)").css("max-width","30%").after(" kg");
jQuery("#"+this.questionId+" input[type='text']:eq(2)").css("max-width","30%").after(" cm");
jQuery("#"+this.questionId+" input[type='text']:last”).css("max-width","30%").after(" cm");


  • Author
  • 10 replies
  • February 8, 2021