Adding an Attribute to a Clicked Element on a Page Being Displayed in an Iframe

Adding an Attribute to a Clicked Element on a Page Being Displayed in an Iframe

Hi all, I am trying to add an attribute to the clicked element on a page that is being displayed in an Iframe. Below is my code inside the document ready function but it is not working:
  1. $('#Iframe').load(function () {
  2.     $(this).contents().find("body").on('click', function (event) {
  3.          var  a = event.target.tagName;
  4.          frameContent = $("#Iframe").contents().find(a);   
  5.          $(frameContent).click(function (e) {   
  6.             if ($(e.target).attr("contenteditable")=="undefined"){
  7.                $(e.target).attr("contenteditable","true")
  8.             }
  9.          });
  10.     }
  11. }

The following layout is similar to the layout of the page being displayed in the iframe
  1. <div>
  2.         sample  
  3.     <div> sample </div>
  4.     <p> sample </p>
  5.     <table><tr><td> sample </td></tr></table>
  6. <div>

I am trying to add the contenteditable to the element that is holding the text I click on.
Please help me solve this problem