jQuery的:
$("#addfav").click(function(){
alert('clicked1');
$("#addfav").attr('id','delfav');
$("#star").attr('src','<?php echo base_url()?>assets/images/star_full.png');
var data = {
pet_id: $("#addfav").attr('data-num')
}
console.log(data);
})
$("#delfav").click(function(){
alert('clicked2');
$("#delfav").attr('id','addfav');
$("#star").attr('src','<?php echo base_url()?>assets/images/star_empty.png');
var data = {
pet_id: $("#delfav").attr('data-num')
}
console.log(data);
})
HTML:
<span data-num="42103" id="addfav" style="cursor:pointer"><img id="star" src="http://newseinstein.com/Rwork/assets/images/star_full.png" alt=""></span>
总是提醒clicked1有人可以帮助我为什么会这样?