0

This is my code. I wanted to make it so that if you click one button it will be disabled and if you click it again it gets enabled. However I can't quite figure it out. Could anyone help me make the thumbnail clickable? That would help a lot. Also could I remove the buttons?

$('.btn ').on('click', function() {
  $(this).prop("disabled", true);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-xs-6 col-md-3">
  <a class="thumbnail">
    <img src="https://getuikit.com/docs/images/placeholder_600x400.svg" alt="Matematik">
    <button type="button" class="btn btn-danger btn-block">Submit</button>
  </a>
</div>
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • A `disabled` element doesn't handle click event and anyway your logic to toggle element `disabled` property on click doesn't really make sense. EDIT: i probably misunderstood your expected behaviour – A. Wolff Dec 04 '16 at 16:13
  • Can u at least tell me how can i make it work? is there anyway u can do both ? – Labinot Krasniqi Dec 04 '16 at 16:18
  • But what is your expected behaviour? Do you mean on click on `thumbnail` (but not the `.btn`) instead? Again, i really don't understand expected behaviour here – A. Wolff Dec 04 '16 at 16:20
  • excuse me for being such a begginer in formulating questions .Is there any way that i can make the button click to disable and if i click it again to bring it to its default behaviour(enable) – Labinot Krasniqi Dec 04 '16 at 16:22
  • I'm sorry but your question doesn't make sense to me. Why would you want to disable an element on click for enable it on next click??? And again, a disabled element doesn't handle click event – A. Wolff Dec 04 '16 at 16:24
  • Im using it to select a category in my line of work and if he wants to remove his choice i didn't want to put an X or smthing but i wanted to give him the choice of clickin it again. – Labinot Krasniqi Dec 04 '16 at 16:25
  • Maybe this would fit your needs: http://stackoverflow.com/a/3100395/1414562 ?! – A. Wolff Dec 04 '16 at 16:29

0 Answers0