sanitizer
sanitizer

Reputation: 105

Removing a div class with Javascript or jQuery on page load

Unsure if anybody is familiar with TypeForm. I am currently testing their forms but its very limited to options with regards to optional items such as incremental question numbers, bullet points & * for required questions.. Ive attached a screenshot of the exact item shown in the dev window that I wish to remove, how is this possible on page load using Javascript or jQuery? i.e. document.getElementsByClassName("Item");

EDIT The way typeform is embedded is as shown in the snippet below:

Much appreciated !! item to remove in google chrome dev view

<div class="typeform-widget" data-url="https://12837r8yhe.typeform.com/to/sKcd9C" style="width: 100%; height: 500px;" > </div> <script> (function() { var qs,js,q,s,d=document, gi=d.getElementById, ce=d.createElement, gt=d.getElementsByTagName, id="typef_orm", b="https://embed.typeform.com/"; if(!gi.call(d,id)) { js=ce.call(d,"script"); js.id=id; js.src=b+"embed.js"; q=gt.call(d,"script")[0]; q.parentNode.insertBefore(js,q) } })() </script>

Upvotes: 0

Views: 3787

Answers (3)

rjustin
rjustin

Reputation: 1439

$("div.item").remove() should do the trick as long as there arent other divs with the item class..

$('div.item').remove();

or

$('div.item').first().remove();

Upvotes: 0

clearshot66
clearshot66

Reputation: 2302

On page load you can do this to remove all instances of the class

$(document).ready(function(){
  $('.Item').remove('Item');
});

Or just the class on divs

$(document).ready(function(){
  $('div .Item').remove('Item');
});

Upvotes: 1

bhansa
bhansa

Reputation: 7504

You can remove or hide it using jquery when the page loads. But it will remove all the div items which have class .item

$(document).ready(function(){
  $("div.item").remove();
  console.log("removed");
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<p>Div item was here but removed when page loaded.</p>
<div class="item">1 ></div><span>Just before me</span>

Upvotes: 0

Related Questions