开票与送货地址/删除开票选项相同

时间:2013-07-30 10:46:40

标签: jquery magento

我是jquery的新手。我正在开发一个电子商务网站。有一个帐单地址。存在用户必须为帐单邮寄地址提供的物理地址的问题。但如果帐单邮寄地址与送货地址相同,则应隐藏编辑送货地址的链接。

所以我认为jQuery可以做到删除链接的技巧。我想知道如何使用jQuery来解决这个问题

1 个答案:

答案 0 :(得分:1)

一个非常概括的例子

$('#ship, #bill').change(function() {
  var bill_val = $('#bill').val(); // save the current values in vars
  var ship_val = $('#ship').val();
  console.log(bill_val + ' = ' + ship_val) // debug purposes
  if (bill_val === ship_val && bill_val.trim().length && ship_val.trim().length) {
  // the if above checks to see if they are the same and if they aren't just spaces
    $('.edit').fadeOut(); //or .hide() for no fade
  } else {
    $('.edit').fadeIn(); //or .show() for no fade
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type='text' id='ship' />
<input type='text' id='bill' />
<a href='javascript:;' class='edit'>Edit</a>

此示例可以调整为仅接受数字,更多地修剪空格以及根据需要进行其他检查。

相关问题