admin管理员组文章数量:1389853
I have a <div>
element. In this <div>
there is a <table>
and <span>
elements. And the <span>
does not have a html id attribute.
I want to change font-size in the <span>
. Can I do it with javascript or jQuery?
I try change class and directly give property with CSS, but they are not working.
How can I change font size?
my <div class="xxx">
and in the style
.xxx {
background-image:url('../k_g.png');
cursor: pointer;
background-repeat: no-repeat;
background-position: center 0%;
font-size:40px;
}
I have a <div>
element. In this <div>
there is a <table>
and <span>
elements. And the <span>
does not have a html id attribute.
I want to change font-size in the <span>
. Can I do it with javascript or jQuery?
I try change class and directly give property with CSS, but they are not working.
How can I change font size?
my <div class="xxx">
and in the style
.xxx {
background-image:url('../k_g.png');
cursor: pointer;
background-repeat: no-repeat;
background-position: center 0%;
font-size:40px;
}
Share
Improve this question
edited Feb 24, 2014 at 11:29
user3086226
asked Feb 24, 2014 at 10:24
user3086226user3086226
931 gold badge7 silver badges18 bronze badges
3
- 1 Please add some code here of what you tried. – Harry Bomrah Commented Feb 24, 2014 at 10:25
- I edit my question. I want to change my div class when I change it I want to change font size. but it does not work – user3086226 Commented Feb 24, 2014 at 10:27
- Setup fiddle, there is not enough data for proper answer. – sinisake Commented Feb 24, 2014 at 10:28
5 Answers
Reset to default 2If you span is not a direct child of the div with the class you could do
.xxx span {
font-size: 40px;
}
However this will affect all spans inside the div and can have unforeseen consequences in the future.
You can apply the below CSS,
.xxx > span {
font-size:40px;
}
try
$(document).ready(function () {
$(".xxx").css("font-size", "200%");
});
Use:
$("div.xxx").children("span").css( "font-size", "30px" );
The first I wonder if this div with .xxx class was create before you call your script or not? If it's ok so just run this script in document.ready function in jQuery:
$(".xxx").css({font-size:"30px"});
or jQuery.noConflict();jQuery(".xxx").css({font-size:"30px"});
instead of you run some libraries using the same $ for that script.
本文标签: javascriptHow can I change div inner HTML font sizeStack Overflow
版权声明:本文标题:javascript - How can I change div inner HTML font size? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744564309a2612955.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论