-1

如果它是一件事并执行另一项任务,我将检查函数返回的值,但否则它不起作用?

$.post('ajaxs.php', {
      name: name_,
      mail: mail_,
      matn: matn_,
      url: url_,
      id: id_
  },function (data) {
      $('#readmore').html(data);

      if (data == 1) {
          $('#readmore').css({
              "border-color": "#00CC00",
              "border-width": "1px",
              "border-style": "solid"
          });
      } else {
          $('#readmore').css({
              "border-color": "#ff0000",
              "border-width": "1px",
              "border-style": "solid"
          });
      }
});
4

1 回答 1

0

尝试类似:

$.post('ajaxs.php', {
    name: name_,
    mail: mail_,
    matn: matn_,
    url: url_,
    id: id_
}, function (data) {
    $('#readmore').html(data)
               .css('border', '1px solid ' + $.trim(data) == "1" ?  '#00CC00' : '#ff0000');
});
于 2013-03-14T11:59:38.980 回答