[英]INSERT HTML markup using before selector
#twitter-widget-0 li div.header::before{
content: '<div> <img src="images/home/twt-icon.png"> </div>';
}
I want to insert the specified HTML using HTML's before selector. 我想使用HTML的before选择器插入指定的HTML。
But it shows markup as it is. 但是它按原样显示标记。
Actually it is a Twitter Embedded Widget
created with https://twitter.com/settings/widgets/new and I want to show that image on every tweet. 实际上,这是一个使用https://twitter.com/settings/widgets/new创建的
Twitter Embedded Widget
,我想在每条推文上显示该图像。
I tried it with JQuery too but with JQuery it does not append anything. 我也尝试过使用JQuery,但是使用JQuery时它不附加任何内容。
$(document).ready(function () {
console.log("debug1");
$("#twitter-widget-0 li div.header").prepend('<div class="boxthreelefts-right" style=" text-align: eig;"> <img src="images/home/twt-icon.png"> </div>');
});
Try this (if your code not inside iframe): 尝试以下操作(如果您的代码不在iframe中):
I tested it works (In page): 我测试了它的工作原理(在页面中):
<div id="twitter-widget-0">
<ul>
<li>
<div class="header"></div>
</li>
<li>
<div class="header"></div>
</li>
<li>
<div class="header"></div>
</li>
</ul>
</div>
<script>
$(function(){
$('#twitter-widget-0 li div.header').each(function(key,value){
$(this).before('<div class="boxthreelefts-right" style="text-align: eig;"> <img src="images/home/twt-icon.png"> </div>');
});
});
</script>
You can do it by CSS and jQuery, but unfortunately content:
does not support HTML 您可以通过CSS和jQuery来完成此操作,但不幸的是
content:
不支持HTML
content syntax is like below : 内容语法如下:
content: normal|none|counter|attr|string|open-quote|close-quote|no-open-quote|no-close-quote|url|initial|inherit;
as it does not support HTML, you can give it URL and set it's position 由于它不支持HTML,因此您可以为其指定URL并设置其位置
like this 像这样
content:url('images/home/twt-icon.png');
But I recommend using jQuery to append HTML to the elements. 但是我建议使用jQuery将HTML附加到元素上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.