Javascript 替换div中的文本
如何删除文本Javascript 替换div中的文本,javascript,jquery,html,css,Javascript,Jquery,Html,Css,如何删除文本 关于我们和在 我试着去做 $(“div.second”)。替换为(“”) 但是它需要一些课程。。但我只是想了解一下我们我该怎么做 <div class="footer-block"> <div id="custom-menu-wizard-2"><h4>About Us</h4><div class="menu-footer_about_menu-container"> <ul id="menu-footer_abo
关于我们
和
在
我试着去做
$(“div.second”)。替换为(“”)代码>
但是它需要一些课程。。但我只是想了解一下我们
我该怎么做
<div class="footer-block">
<div id="custom-menu-wizard-2"><h4>About Us</h4><div class="menu-footer_about_menu-container">
<ul id="menu-footer_about_menu" class="menu-widget " data-cmwv="3.1.3"><li id="menu-item-1054"><a href="http://projects.bizarresoftware.in/innomations/?page_id=38&tab=1">Corporate Profile</a></li>
<li id="menu-item-1055" class="menu-item menu-item-type-custom menu-item-object-custom cmw-level-1 menu-item-1055"><a href="http://projects.bizarresoftware.in/innomations/?page_id=38&tab=2">Vision</a></li>
<li id="menu-item-1056" class="menu-item menu-item-type-custom menu-item-object-custom cmw-level-1 menu-item-1056"><a href="http://projects.bizarresoftware.in/innomations/?page_id=38&tab=3">Mission</a></li>
<li id="menu-item-1057" class="menu-item menu-item-type-custom menu-item-object-custom cmw-level-1 menu-item-1057"><a href="http://projects.bizarresoftware.in/innomations/?page_id=38&tab=4">Core Team</a></li>
</ul>
</div>
</div>
关于我们
注意:
我不能简单地用替换,因为它将替换页面中的所有
h4
。。如何遍历页脚块
,然后进行替换。$(“.footer block h4”).html(“”)代码>$(“.footer block h4”).html(“”)代码>您可以使用html的回调函数:
$('#custom-menu-wizard-2 h4').html(function(){
return "<a href='#aboutus'/>" + $(this).html() + "</a>");
});
$('#custom-menu-wizard-2h4').html(函数(){
返回“”);
});
您可以使用html的回调函数:
$('#custom-menu-wizard-2 h4').html(function(){
return "<a href='#aboutus'/>" + $(this).html() + "</a>");
});
$('#custom-menu-wizard-2h4').html(函数(){
返回“”);
});
试试看
$( "#custom-menu-wizard-2 h4:first-child").replaceWith( "<h4><a href='#aboutus'>About Us</a></h4>" );
$(“#custom-menu-wizard-2h4:第一个子项”)。替换为(“”);
试试看
$( "#custom-menu-wizard-2 h4:first-child").replaceWith( "<h4><a href='#aboutus'>About Us</a></h4>" );
$(“#custom-menu-wizard-2h4:第一个子项”)。替换为(“”);
$('#自定义菜单向导-2')。查找('h4')。删除();
$('#custom-menu-wizard-2').html('';
考虑到“#custom-menu-wizard-2
”$(“#custom-menu-wizard-2”)中没有其他元素或文本。查找('h4')。删除();
$('#custom-menu-wizard-2').html('';
考虑到“#custom-menu-wizard-2
”中没有其他元素或文本,replacetwith
函数没有错误,您只需放置正确的选择器“#custom-menu-wizard-2 h4”
$('#custom-menu-wizard-2 h4')。替换为(“”)代码>
关于我们
使用ReplaceWith
功能没有错误,您只需将正确的选择器'#custom-menu-wizard-2 h4'
$('#custom-menu-wizard-2 h4')。替换为(“”)代码>
关于我们
您可以使用wrapInner()jsfiddle:
$('.footer block h4').wrapInner(“”)
您可以使用wrapInner()jsfiddle:
$('.footer block h4').wrapInner(“”)
您需要使用替换为
$('#custom-menu-wizard-2 h4')。替换为(“”);
您需要使用替换为
$('#custom-menu-wizard-2 h4')。替换为(“”);
$(“.footer block h4”)。替换为(“”);
$(“.footer block h4”)。替换为(“”);
$(“div#custom-menu-wizard-2h4”)。替换为(“”);
$(“div#custom-menu-wizard-2 h4”)。替换为(“”);
您不能直接在#custom-menu-wizard-2下选择h4并使用replaceWizard。您不能直接在#custom-menu-wizard-2下选择h4并使用replaceWizard。您的第二行将删除$('#custom-menu-wizard-2')中的所有内容,只需在其中添加一个链接。您的第二行将删除$('#custom-menu-wizard-2'中的所有内容)只需在Mine is div中添加一个链接,将脚本替换为
或
我的is div,将脚本替换为
或
一般来说,如果答案中包含对代码意图的解释,那么答案会更有帮助,为什么不引入其他人就解决了问题。(这篇文章至少有一位用户标记过,大概是因为他们认为应该删除一个没有解释的答案。)–一般来说,如果答案中包含对代码意图的解释,以及在不介绍其他人的情况下解决问题的原因,那么答案会更有帮助。(这篇文章至少有一位用户标记,大概是因为他们认为应该删除没有解释的答案。)
$( '#custom-menu-wizard-2 h4' ).replaceWith( "<h4><a href='#aboutus'>About Us</a></h4>" );
$( ".footer-block h4" ).replaceWith( "<a href='#aboutus'>About Us</a>" );
$("div#custom-menu-wizard-2 h4").replaceWith('<h4><a href=\'#aboutus\'>About Us</a></h4>');