Can someone help me in this? I want to remove a class on button click, but it works only after 1 click is already done. when i click first time, nothing happens. when i click second time, class is removed HTML Code
<%= form_for :email_form, :html => {:class => "form-horizontal"}, url: search_reduce_credits_by1_path, id: "candidate-email-modal-form", remote: true do |f| %>
<%= f.hidden_field :lead_id, :value => lead.id %>
<div class=text-right>
<%= f.button class: "btn btn-primary", id: "show-mail-btn" do %>
Show Email
<% end %>
</div>
<% end %>
<small class="blurfilter" id="blurred_email_<%= lead.id %>"> <%= lead.email %></small>
JQuery:
$(document).ready(function (){
$('#show-mail-btn').click(function (){
$('#blurred_email_1').removeClass('blurfilter');
});
});
When I update jquery to this,
$(document).on('click', '#show-mail-btn', function(){
alert("Hey");
$('#blurred_email_1').removeClass('blurfilter');
});
"Hey" also appears on second click and appears two times, before class is removed.