0

I am working in wordpress and my ajax function result showed one button whose html is mentioned below. Now I want to run a click event on that button but when I click it nothing happens. Below is the html and jquery code of the button I am using and kindly note that this button is shown as a result of an ajax operation. thanks !!

html

<input style="background-color:purple" id="readmore" type="button" value="Readmore!!" name="mybutton">

jquery

jQuery("#readmore").on('click', function(e){
    e.preventDefault();
    alert("you clicked the button");
    jQuery("#bodytext").css("display","block");
});
Zeeshan
  • 323
  • 1
  • 7
  • 23
  • have you enclosed this in ```$(document).ready(function(){///code here});```. – Paul Fitzgerald Apr 25 '15 at 09:31
  • 1
    Since you have said `my ajax function result showed one button`, It looks like you are dealing with a dynamic element, so try `$(document).on('click', '#readmore', function(){//your stuff})` – Arun P Johny Apr 25 '15 at 09:32

0 Answers0