Loading ...
Sorry, an error occurred while loading the content.

jquery conditional css gives: Weird ternary.

Expand Messages
  • bartman1c
    /*global $ */ var $my_element = $( #myelementid ), $element_a = $( #elementaid ), $element_b = $( #elementbid ); $my_element.css( $element_a.width() +
    Message 1 of 3 , Oct 1, 2012
    • 0 Attachment
      /*global $ */
      var $my_element = $('#myelementid'), $element_a = $('#elementaid'), $element_b = $('#elementbid');
      $my_element.css(
      $element_a.width() + $element_b.width() > $my_element.parent().width() ? {'top': '18px', 'width': '63'} : {'top': '5px', 'width': 'auto'}
      );

      Not sure if it is jslint issue, what would be the "not weird" alternative?
    • douglascrockford
      ... Thanks. Please try it now.
      Message 2 of 3 , Oct 1, 2012
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "bartman1c" <bartman1c@...> wrote:
        >
        > /*global $ */
        > var $my_element = $('#myelementid'), $element_a = $('#elementaid'), $element_b = $('#elementbid');
        > $my_element.css(
        > $element_a.width() + $element_b.width() > $my_element.parent().width() ? {'top': '18px', 'width': '63'} : {'top': '5px', 'width': 'auto'}
        > );
        >
        > Not sure if it is jslint issue, what would be the "not weird" alternative?


        Thanks. Please try it now.
      • bartman1c
        ... Is not weird anymore, thank you.
        Message 3 of 3 , Oct 2, 2012
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "douglascrockford" <douglas@...> wrote:
          >
          > --- In jslint_com@yahoogroups.com, "bartman1c" <bartman1c@> wrote:
          > >
          > > /*global $ */
          > > var $my_element = $('#myelementid'), $element_a = $('#elementaid'), $element_b = $('#elementbid');
          > > $my_element.css(
          > > $element_a.width() + $element_b.width() > $my_element.parent().width() ? {'top': '18px', 'width': '63'} : {'top': '5px', 'width': 'auto'}
          > > );
          > >
          > > Not sure if it is jslint issue, what would be the "not weird" alternative?
          >
          >
          > Thanks. Please try it now.
          >

          Is not weird anymore, thank you.
        Your message has been successfully submitted and would be delivered to recipients shortly.