i want to edit content inside the "pre" tag. On a button click i want to know whether the content is changed or not. How can i possible this using "jquery"?
Asked
Active
Viewed 868 times
0
-
[jQuery Learning Center](https://learn.jquery.com) – Andreas Jan 09 '17 at 06:47
-
`pre` tag is not input tag and does not have `change` event – Justinas Jan 09 '17 at 06:48
-
is it possible only with input tag? by adding an attribute conetnteditable=true we can edit content inside all elements. then there should be a way in jquery to trigger that change. – Nighina t t Jan 09 '17 at 06:52
-
Possible duplicate of [Jquery Event : Detect changes to the html/text of a div](http://stackoverflow.com/questions/15657686/jquery-event-detect-changes-to-the-html-text-of-a-div) – caramba Jan 09 '17 at 06:55
-
@Nighinatt did my answer help you? – caramba Jan 09 '17 at 11:13
-
yes .. thank u for your help – Nighina t t Jan 10 '17 at 04:02
1 Answers
0
You can use: DOMSubtreeModified
$('.change-text-button').on('click', function(){
$('.my-pre').text('Some other text');
});
$('.my-pre').bind("DOMSubtreeModified",function(){
console.log('changed');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="change-text-button">Change text</button>
<pre class="my-pre">Lorem ipsum dolor sit amet</pre>

caramba
- 21,963
- 19
- 86
- 127