<!DOCTYPE html>
<
html
>
<
head
>
<
script
src
=
</
script
>
<
style
>
div {
padding: 20px;
outline: none;
}
p {
color: grey;
outline: none;
padding: 20px;
}
</
style
>
</
head
>
<
body
>
<
div
>
<
h1
>
Welcome to GeeksforGeeks
</
h1
></
div
>
<
p
contenteditable
=
"true"
>
Welcome to GeeksforGeeks
</
p
>
<
script
>
//checking div tag as attribute contenteditable
$(document).ready(function() {
$("div").change(function() {
var conattr = $(this).attr('contenteditable');
if (typeof conattr !== typeof undefined && conattr !== false) {
//if div tag as attribute contenteditable
$(this).css('border', 'solid 2px red');
} else {
//if doesn't have div tag as attribute contenteditable
$(this).css({
"border": "solid 2px green",
"border-radius": "34px"
}).attr('contenteditable', 'true')
}
}).trigger("change");
});
//checking p tag as attribute contenteditable
$(document).ready(function() {
$("p").change(function() {
var conattr = $(this).attr('contenteditable');
if (typeof conattr !== typeof undefined && conattr !== false) {
//if p tag as attribute contenteditable
$(this).css('border', 'solid 2px red');
} else {
//if doesn't have p tag as attribute contenteditable
$(this).css({
"border": "solid 2px green",
"border-radius": "34px"
}).attr('contenteditable', 'true')
}
}).trigger("change");
});
</
script
>
</
body
>
</
html
>