for some reason when using insertAdjacentHtml function in FF I am getting insertAdjacentHTMl is not a function error, is there an alternative to this in jQuery or some other alternative javascript function?
It depends on how you're using it.
.insertAdjacentHTML("beforeBegin", ...) //$('...').before(...)
.insertAdjacentHTML("afterBegin", ...) //$('...').prepend(...)
.insertAdjacentHTML("beforeEnd", ...) //$('...').append(...)
.insertAdjacentHTML("afterEnd", ...) //$('...').after(...)
http://api.jquery.com/before/
http://api.jquery.com/after/
http://api.jquery.com/append/
http://api.jquery.com/prepend/
$('<p class="border">PrependTo</p>').prependTo($('.main'));
$('.main').prepend('<p class="border">Prepend</p>');
$('<p class="border">AppendTo</p>').appendTo($('.main'));
$('.main').append('<p class="border">Append</p>');
$('<p class="border">Insert After</p>').insertAfter('.main');
$('<p class="border">Insert Before</p>').insertBefore('.main');
.border {
border: 1px solid #000;
margin: 10px;
padding: 5px 15px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="main border">
<p>Main</p>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With