0

Imagine, there are two files

  1. test.php
  2. index.php

In test.php there are only a html button with id click.

In index.php there are also only a html button with id send.

If I send an ajax request to test.php file from index.php then the button with id click from test.php should be inserted within a div in index.php. Now I want this button to hide p element when it is clicked within index.php.

Note: onclick attribute should not come with #click button.

How to do that? I am currently using android phone to ask this question. So I am not able to write the question with examples.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
Arif Billah
  • 157
  • 2
  • 11

1 Answers1

0
$("#id").live("click",function() {
 alert("hai");
})

EDIT

$("#id").on("click",function() {
   alert("hai");
})

OR

$("#id").delegate("click",function() {
   alert("hai");
})
Kiren S
  • 3,037
  • 7
  • 41
  • 69
  • 2
    `.live()` was deprecated in jQuery 1.7 and removed in 1.9. You shouldn't be recommending it, use `.on()`. – Barmar Jan 08 '15 at 08:50
  • @KirenSiva so please consider fixing your answer! – Alnitak Jan 08 '15 at 09:23
  • None of these work anyway. They rely on the element being present. (Well, `delegate` *might* work, but I've never used it in favour of `$(someParentElement).on("click", ".selector", function(){...});`...) – Niet the Dark Absol Dec 20 '15 at 17:06