So I have an icon that is essentially an open close button.
So when you open it, it turns red and rotates 45
degrees. Now here's the issue. Since its open, I can't close it. Since if I change the div class the icon won't show while its in an active state. Here's the jQuery I'm using
$(".fa-plus").click(function() {
$(".form").removeAttr("style");
$('.fa-plus').css('-webkit-transform', 'rotate(45deg)');
$('.fa-plus').css('-webkit-transition', '0.25s');
$('.fa-plus').css('color', '#FF0000');
$(".fa-plus").attr("id", "test");
});
This basically opens it, and ads an #id
called test
. And what happens is when I click on the icon which is named #test
. It won't display an alert with this code, it only displays the alert when I press the +
, not X
$("#test").click(function() {
alert('test');
});
Here's a demo. I only want the alert when you click on the red X