$('.dialog button').click(function () { if($(this).attr('class') == 'true') { $('p').text('Ok was clicked'); } else { $('p').text('Cancel was clicked'); } });
.dialog { background-color: #cecece; border: 1px solid #000; padding: 1%; font-family: 'Segoe UI'; text-align: center; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="dialog"> <button class="true">Ok</button> <button class="false">Cancel</button> </div> <p></p>
Answer
You can determine which button was pressed. For example, in the dialog box there are buttons with a class, either true or false. how
<div class="dialog"> <button class="true">Ok</button> <button class="false">Cancel</button> </div>
you can handle jQuery for this as
$('.dialog button').click(function () { if($(this).attr('class') == 'true') {
This was only one approach, you can even use data- tags to add additional features. But I donβt think that JavaScript has any logical values ββ(jQuery is a JavaScript library, it will only have JavaScript functions).
You can try the above code to check it. It also has a basic style, and buttons are used to determine if the user has chosen the true or false thing. This is a custom confirmation flag. jQuery processes it, and then, provided that the reference value records at p .
source share