如何通过jquery-1.11.0.min版本hide/change一个div元素内容
How to hide/change a div element content by jquery-1.11.0.min version
我有一个 div 元素,如下所示加载到我的 vbulletin 主题中代码末尾(正好在 </body>
标记之前),我如何通过添加删除此 div javascript 代码?或更改其内容? jquery-1.11.0.min 加载到我的主题中,因此如果可能的话,与我分享可以使用此 jquery 版本执行此操作的解决方案。
div 元素:
<div style="position: absolute!important;z-index: 99999999999999999999!important;font-family: Yekan;display: block!important;color: #FFF!important;width: 100%!important;text-align: center;background: #2B2D3B!important;padding: 1px 0 7px 0;" id="dgh">
طراحی شده با
<i class="icon-heart"></i>
توسط
<a href="http://aliz1212.ir">علیزاده</a>
در
<a href="http://www.iranforum.ir">ایران فروم</a>
.</div>
考虑到我不能在 div 标签之后插入 javascript 代码,只能在 div 元素之前添加 javacode 代码,我也知道我不能覆盖css 的内联重要样式。谢谢
$(document).ready(function(){
// find the last div in body
var lastDiv = $('#dgh');
// remove the div ...
lastDiv.remove();
// ... or change it's content
lastDiv.html('new content goes hier');
});
简单,只需使用您的 ID 来删除或更新元素
$(document).ready(function(){
$('#dgh').remove();
//or
$('#dgh').html('Your content goes here');
});
我有一个 div 元素,如下所示加载到我的 vbulletin 主题中代码末尾(正好在 </body>
标记之前),我如何通过添加删除此 div javascript 代码?或更改其内容? jquery-1.11.0.min 加载到我的主题中,因此如果可能的话,与我分享可以使用此 jquery 版本执行此操作的解决方案。
div 元素:
<div style="position: absolute!important;z-index: 99999999999999999999!important;font-family: Yekan;display: block!important;color: #FFF!important;width: 100%!important;text-align: center;background: #2B2D3B!important;padding: 1px 0 7px 0;" id="dgh">
طراحی شده با
<i class="icon-heart"></i>
توسط
<a href="http://aliz1212.ir">علیزاده</a>
در
<a href="http://www.iranforum.ir">ایران فروم</a>
.</div>
考虑到我不能在 div 标签之后插入 javascript 代码,只能在 div 元素之前添加 javacode 代码,我也知道我不能覆盖css 的内联重要样式。谢谢
$(document).ready(function(){
// find the last div in body
var lastDiv = $('#dgh');
// remove the div ...
lastDiv.remove();
// ... or change it's content
lastDiv.html('new content goes hier');
});
简单,只需使用您的 ID 来删除或更新元素
$(document).ready(function(){
$('#dgh').remove();
//or
$('#dgh').html('Your content goes here');
});