javascript - add jQuery click event to code behind generated button -


a button(replybtn) created onclick in code behind.
--default.aspx.cs--

protected void reloadthepaneldetails_click(object sender, eventargs e) {   litresultdetails.text = litresultdetails.text +   "<button id='replybtn' onclick='replyfunc(this); return false;'>reply thread</button><br />"; } 

--default.aspx--
click on replybtn using javascript

 <script type = "text/javascript">  function replyfunc(obj1) {      document.getelementbyid(obj1.id).click();   } </script> 

use jquery click event replybtn

<script> $(document).ready(function () {  $('.replypanel').css({ "display": "none" }); //div default no display     $("#replybtn").click(function () {       //onclick div display         $('.replypanel').css({ "display": "block" });     }); }); </script> 

the div not displaying onclick of replybtn (which generated in code behind). please suggest other solution or update required above.

you need use event delegation , listening dynamically generated dom element

<script> $(document).ready(function () {  $('.replypanel').css({ "display": "none" }); //div default no display     $(document).on('click',"#replybtn",function () {       //onclick div display         $('.replypanel').css({ "display": "block" });     }); }); </script> 

Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -