How can I disable the div using jquery before button submit -
i have 2 divs called "yes" , "no"
<div id="object"> <div class="object-content"> i'd <div class="confirm" id="btnyes" runat ="server" >yes</div> </div> <div class="object-content" style="float: right"> i'd <div class="confirm" style="color: red" id="btnno" runat="server">no</div> </div> </div> and 1 comment button called "post"
<asp:button id="btnposturcomment" onclick="btnposturcomment_click" runat="server" text="post comment" height="33px" class="ppig" /> when straight click on "post" alert "please select yes or no clicking on them" , click on "yes" or "no" div alert "you said "yes" or "no" "
now problem , after if click "yes" div "no" div disable not hide before click on "post" button , vice versa .
i trying script. please guide me.
<script> $(document).ready(function () { var ispostcomment = false; var clickedelement = ""; $('.confirm').click(function () { ispostcomment = true; clickedelement = $(this).text(); }); $('#<%=btnposturcomment.clientid %>').click(function () { if (ispostcomment) { alert("you said " + clickedelement); } else { alert("please select yes or no clicking on them") homecoming false; } }); }); </script>
try :
<script> $(document).ready(function () { var ispostcomment = false; var clickedelement = ""; $('.confirm').click(function () { // disable other button var disablebtnid = ($(this).attr('id')=='btnyes')?'btnno':'btnyes'; $('#'+disablebtnid).prop('disabled',true); ispostcomment = true; clickedelement = $(this).text(); }); $('#<%=btnposturcomment.clientid %>').click(function () { // enable both buttons $('.confirm').removeprop('disabled'); if (ispostcomment) { alert("you said " + clickedelement); } else { alert("please select yes or no clicking on them") homecoming false; } }); }); </script> jquery
No comments:
Post a Comment