如果里面的文字发生了变化,我有什么方法可以提醒吗?
开始:
<span class="badge badge-cart">Shopping bag (0)</span>
点击更改为
<span class="badge badge-cart">Shopping bag (1)</span>
因此,如果()内的数字已更改显示警告
答案 0 :(得分:1)
var $span = $('span.badge-cart'),
$submit = $('input'),
text = $span.text();
$submit.on('click', function () {
if($span.text() !== text) {
alert('text has changed');
text = $span.text();
}
});