Sure — add the attribute canAppend="no"
to an element then use the attribute selector like this:
$(document).ready(function() {
/* add the attribute selector [canAppend!="no"] to your select or */
$("div[canAppend!='no']").append(" appended content here");
});
div { border: 2px solid black }
<!-- regular divs that dont have the noAppend attribute -->
<div>div 1</div>
<div> div 2</div>
<!-- special div that has the noAppend attribute -->
<div canAppend='no'>div 3 no append </div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
EDIT
Since you dont know when the append operation will take place, just do this:
use jQuery to grab all of the values of for divs with a certain class and store those values into an atttribute by using encodeURIComponent()
and $("").attr()
THen make a timer that constantly replaces the div’s HTML with the desired HTML
$(document).ready(function() {
$(".someHtmlElementHereWillAppendOnPageLoad").each(function(i, ele) {
$(ele).attr("lockedContents", encodeURI($(ele).html()))
});
setInterval(function() {
$(".someHtmlElementHereWillAppendOnPageLoad").each(function(i, ele) {
$(ele).html(decodeURIComponent($(ele).attr("lockedContents")));
})
}, 100);
});
div {
border: 1px solid black
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="someotherdiv">#1 dont care if it gets edited</div>
<br>
<div class="someHtmlElementHereWillAppendOnPageLoad">
-- but it dont want this part to be appended --
</div>
<br>
<button value="append to all divs" onclick="$('div').append(' appended text ');">Append to all divs </button>
3
solved Disable an element/class/id from append? [closed]