简体   繁体   English

在页面加载时使用Javascript或jQuery删除div类

[英]Removing a div class with Javascript or jQuery on page load

Unsure if anybody is familiar with TypeForm. 不确定是否有人熟悉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? 我目前正在测试其表格,但对于可选项目(例如递增问题编号,项目符号和*必填问题),其范围非常有限。Ive已附上了我希望删除的开发窗口中显示的确切项目的屏幕截图,使用Javascript或jQuery在页面加载时怎么可能? ie document.getElementsByClassName("Item"); 即document.getElementsByClassName(“ Item”);

EDIT The way typeform is embedded is as shown in the snippet below: 编辑 typeform的嵌入方式如以下代码片段所示:

Much appreciated !! 非常感激 !! 谷歌浏览器开发人员视图中要删除的项目

 <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> 

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 或者只是div上的课程

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

$("div.item").remove() should do the trick as long as there arent other divs with the item class.. $(“ div.item”)。remove()应该可以解决问题,只要项目类中没有其他div。

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

or 要么

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

You can remove or hide it using jquery when the page loads. 您可以在页面加载时使用jquery删除或隐藏它。 But it will remove all the div items which have class .item 但是它将删除所有具有class .itemdiv项目。

 $(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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM