How to add a condition to select classes in dom option?

How to add a condition to select classes in dom option?

Akshay29Akshay29 Posts: 6Questions: 1Answers: 0

<'blotter-table't><istrue?class-a:class:b>
can i use something like this?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin

    I don't really understand what you want to do I'm afraid. Could you restate that?

    Thanks,
    Allan

  • Akshay29Akshay29 Posts: 6Questions: 1Answers: 0

    If i want to use a class based on a condition i.e use class1 if a variable is true else set class2. Is it possible?

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin

    Oh I see - yes, but not in the string. You'd need to do something like:

    dom: condition ?
      'string1' :
      'string2'
    

    Allan

  • Akshay29Akshay29 Posts: 6Questions: 1Answers: 0

    <' condition ? 'class-a' : 'class-b' 't>
    this is how i tried.. but its not working..

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin

    That doesn't look like valid Javascript to me - I presume you are getting a syntax error in your browser's console? Try it like I suggested above.

  • Akshay29Akshay29 Posts: 6Questions: 1Answers: 0

    I need to add it in a way I have mentioned.. in html page within tags. Could you please suggest a way?

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin
    dom: condition ?
      '<"class-a"t>' :
      '<"class-b"t>';
    

    Allan

  • Akshay29Akshay29 Posts: 6Questions: 1Answers: 0
    edited November 2016

    Thank you Allan.
    Can we use a variable as a class name??

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin
    Answer ✓

    Sure.

  • Akshay29Akshay29 Posts: 6Questions: 1Answers: 0

    Thank you.

This discussion has been closed.