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:
- $('#Iframe').load(function () {
- $(this).contents().find("body").on('click', function (event) {
- var a = event.target.tagName;
- frameContent = $("#Iframe").contents().find(a);
- $(frameContent).click(function (e) {
- if ($(e.target).attr("contenteditable")=="undefined"){
- $(e.target).attr("contenteditable","true")
- }
- });
- }
- }
The following layout is similar to the layout of the page being displayed in the iframe
- <div>
- sample
- <div> sample </div>
- <p> sample </p>
- <table><tr><td> sample </td></tr></table>
- <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