gpt4 book ai didi

html - 更改 getElementsByClassName 的字体大小

转载 作者:太空狗 更新时间:2023-10-29 13:31:20 24 4
gpt4 key购买 nike

我使用 getElementsByClassName 在页面中删除了一个段落。但是,我无法更改输出的字体大小和颜色

下面是我要废弃的代码。

var keyPeople1 = tmp.body.getElementsByClassName("cr_profile_people module")[0].children;
for (var i = 0; i < keyPeople1.length; i++) {
keyPeople1[i].style.fontSize = "2em";
}
$scope.keyPeople = "<div class='cr_profile_people module'><div class='mod_headerBox'>"+keyPeople1[0].innerHTML+"</div><div class='cr_data cr_board'>"+keyPeople1[1].innerHTML+"</div></div>";

for 循环本应更改字体大小,但它不起作用。

html 片段

<div style="margin: 10px;" ng-bind-html="keyPeople"></div>

在样式中添加字体大小<div style="margin: 10px;font-size:60%;"ng-bind-html="keyPeople"></div>对字体大小没有影响。

请指导更改字体大小和颜色的正确方法。 enter image description here

完整代码

angular js 报废页面

.controller("companyOwnershipCtrl",function($scope,$http,$ionicLoading,$state,$cashDataFactory){


$ionicLoading.show();

$http.get("http://vinn.johnapi.com/wsjapi?url=http://quotes.wsj.com/SG/U11/company-people")
.success(function(response){
$ionicLoading.hide();
var tmp = document.implementation.createHTMLDocument();

tmp.body.innerHTML = response;

//Company Info
var companyInfo1 = tmp.body.getElementsByClassName("cr_profile_contact")[0].children;
var companyInfo2 = tmp.body.getElementsByClassName("cr_overview_data cr_data")[0].children;

$scope.companyInfo = "<div class='cr_profile_contact'>"+companyInfo1[0].innerHTML+"</div>";
$scope.companyInfo += "<div class='cr_overview_data cr_data'>"+companyInfo2[0].innerHTML+"</div>";

//Description
var description1 = tmp.body.getElementsByClassName("cr_description_full cr_expand")[0].children;
$scope.companyDescription = "<p>"+description1[0].innerHTML+"</p>";

//Key People
var keyPeople1 = tmp.body.getElementsByClassName("cr_profile_people module")[0].children;
$scope.keyPeople = "<div class='cr_profile_people module'><div class='mod_headerBox'>"+keyPeople1[0].innerHTML+"</div><div class='cr_data cr_board'>"+keyPeople1[1].innerHTML+"</div></div>";

//Average Growth Rates
var growth = tmp.body.getElementsByClassName("cr_profile_growth module")[0].children;
var growth1 = tmp.body.getElementsByClassName("cr_profile_insider module")[0].children;
$scope.averageGrowthRates = "<div class='cr_profile_growth module'><div class='mod_headerBox'>"+growth[0].innerHTML+"</div><div class='cr_data'>"+growth[1].innerHTML+"</div></div>";
$scope.averageGrowthRates += "<div class='cr_profile_insider module'><div class='mod_headerBox'>"+growth1[0].innerHTML+"</div><div class='cr_data'>"+growth1[1].innerHTML+"</div><div class='cr_data'>"+growth1[2].innerHTML+"</div></div>";

//ownership
var ownership = tmp.body.getElementsByClassName("cr_profile_ownership module")[0].children;
$scope.averageGrowthRates += "<div class='cr_profile_ownership module'><div class='mod_headerBox'>"+ownership[0].innerHTML+"</div><div class='cr_data'>"+ownership[1].innerHTML+"</div><div class='cr_data'>"+ownership[2].innerHTML+"</div></div>";
}).error(function(error){

$ionicLoading.hide();
console.log(error.data);

});

html

<ion-view view-title="Company">
<ion-nav-buttons side="left">
</ion-nav-buttons>
<ion-content id="comp">
<ion-scroll>
<h3 style="margin: 10px;">Company Info</h3>
<div style="margin: 10px;" ng-bind-html="companyInfo"></div>
<h3 style="margin: 10px;">Description</h3>
<div style="margin: 10px;font-size:20px;" ng-bind-html="companyDescription"></div>
<div style="margin: 10px;color:#AAAFFF;font-size:40px;" ng-bind-html="keyPeople"></div>s
<div style="margin: 10px;" ng-bind-html="averageGrowthRates"></div>
<div style="margin: 10px;" ng-bind-html="ownership"></div>
</ion-scroll>
</ion-content>
</ion-view>

更新:使用@Manzurul 和@Varun Sukheja 的当前答案。

  1. 我画的红框里面的字体大小和颜色都不生效

  2. 红框下方的表格字体大小不生效,只改变了颜色。

所以我很好奇为什么红框内的字体大小不能改变?更重要的是如何改变它。

图片正在使用

.controller("companyOwnershipCtrl",function($scope,$http,$ionicLoading,$state,$cashDataFactory){

$scope.companyDescriptionStyle = {"color": "blue", "font-size": "40px"};

在 angularjs 和 <div style="margin: 10px;font-size:20px;" ng-bind-html="companyDescription" ng-style="companyDescriptionStyle"></div> 中在 html 中,但您可以注意到字体大小与上面相同。

enter image description here

从此链接中删除的 html 代码 http://quotes.wsj.com/SG/U11/company-people

<div class="cr_profile_people module"> <div class="mod_headerBox"> <h3>Key People <span class="hdr_co_name">United Overseas Bank Ltd.</span></h3> </div> <div class="cr_data cr_board"> <h4>Board of Directors</h4> <table class="cr_dataTable cr_board_table"> <tbody> <tr> <th>Name/Title</th> <th>Current Board Membership</th> </tr> </tbody> </table> <div class="scrollBox"> <table class="cr_dataTable cr_board_table"> <tbody> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/86291589">Ee Cheong Wee</a>, <span class="data_meta">63</span> </span> <span class="data_lbl">Deputy Chairman &amp; Chief Executive Officer</span> </td> <td> <span class="data_lbl">PT Bank UOB Indonesia, Visa International Senior Client Council, United Overseas Bank Ltd., Singapore-China Foundation Ltd., Far Eastern Bank Ltd., United Overseas Insurance Ltd., United Overseas Bank (Thai) Public Co. Ltd., United Overseas Bank (Malaysia) Bhd., The Institute of Banking &amp; Finance, United Overseas Bank (China) Ltd., Wee Foundation, United Overseas Bank Ltd. (Singapore)</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/16055509">Michael Lien</a>, <span class="data_meta"></span> </span> <span class="data_lbl">Non-Executive Director</span> </td> <td> <span class="data_lbl">United Overseas Bank Ltd. (Singapore)</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/104206">Cho Yaw Wee</a>, <span class="data_meta">88</span> </span> <span class="data_lbl">Chairman-Emeritus</span> </td> <td> <span class="data_lbl">United Overseas Bank Ltd. (Singapore)</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/16489539">Fu Hua Hsieh</a>, <span class="data_meta">66</span> </span> <span class="data_lbl">Chairman</span> </td> <td> <span class="data_lbl">United Overseas Bank Ltd. (Singapore)</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/86320739">Khirn Hai Yeo</a>, <span class="data_meta">55</span> </span> <span class="data_lbl">Independent Non-Executive Director</span> </td> <td> <span class="data_lbl">United Overseas Bank Ltd. (Singapore)</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/154674047">Kan Seng Wong</a>, <span class="data_meta">71</span> </span> <span class="data_lbl">Independent Non-Executive Director</span> </td> <td> <span class="data_lbl">United Overseas Bank Ltd. (Singapore)</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/13470908">Alexander Charles Hungate</a>, <span class="data_meta">51</span> </span> <span class="data_lbl">Independent Non-Executive Director</span> </td> <td> <span class="data_lbl">United Overseas Bank Ltd. (Singapore)</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/98308786">Hwee Hua Lim</a>, <span class="data_meta">57</span> </span> <span class="data_lbl">Independent Non-Executive Director</span> </td> <td> <span class="data_lbl">United Overseas Bank Ltd. (Singapore), BW Group Ltd., Jardine Cycle &amp; Carriage Ltd., Stewardship &amp; Corporate Governance Centre Pte Ltd., PAP Community Foundation, Stewardship Asia Centre Pte Ltd.</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/104667">Cher Siang Koh</a>, <span class="data_meta">70</span> </span> <span class="data_lbl">Independent Non-Executive Director</span> </td> <td> <span class="data_lbl">Singapore Housing &amp; Development Board, United Overseas Bank Ltd., CapitaLand Ltd., United Overseas Bank Ltd. (Singapore), Thye Hua Kwan Moral Charities Ltd., Mechanobiology Institute, Singapore Golf Association, Singapore Cooperation Enterprise, CapitaLand Hope Foundation, Singapore Deposit Insurance Corp., Singapore Island Country Club</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/114522422">Yew Huat Ong</a>, <span class="data_meta">60</span> </span> <span class="data_lbl">Independent Non-Executive Director</span> </td> <td> <span class="data_lbl">United Overseas Bank Ltd. (Singapore)</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/86318967">Jue Hiang Cheng</a>, <span class="data_meta">62</span> </span> <span class="data_lbl">Independent Non-Executive Director</span> </td> <td> <span class="data_lbl">SPH MediaBoxOffice Pte Ltd., SPH Interactive Pte Ltd., FEO Hospitality Trust Management Pte Ltd., Far East Hospitality Trust, FEO Hospitality Asset Management Pte Ltd., SPH Interactive International Pte Ltd., Singapore Institute of Directors, 701Search Pte Ltd., Ntuc Fairprice Foundation Ltd., Ashoka Innovators for the Public (Singapore) Ltd., United Overseas Bank Ltd. (Singapore), Council For Third Age Ltd., Integrated Information Systems, Inc., Aescapulus Holdings Pte Ltd., Singapore Health Services Pte Ltd., Integrated Health Information Systems Pte Ltd., SymAsia Foundation Ltd., Asia Philantrophic Ventures Pte Ltd., Asia Philanthropic Ventures Pte Ltd., Caritas Humanitarian Aid &amp; Relief Initiatives, Singapore</span> </td> </tr> <tr> <td> <span class="data_data"> <a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/41491049">Franklin Leo Lavin</a>, <span class="data_meta">58</span> </span> <span class="data_lbl">Independent Non-Executive Director</span> </td> <td> <span class="data_lbl">Far Eastern Bank Ltd., Globe Specialty Metals, Inc., CONSISTEL (Singapore) Pte Ltd., United Overseas Bank Ltd. (Singapore), United Overseas Bank Ltd., Export Now, Inc.</span> </td> </tr> </tbody> </table> </div> <div class="bottomStrap_more"> <a href="#" id class="moreLink loadMoreLink">expand</a> </div> </div> <div class="cr_data cr_all_executives"> <h4>All Executives</h4> <div class="scrollBox"> <ul class="cr_data_collection cr_all_executives"> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/86291589">Ee Cheong Wee</a></span> <span class="data_lbl">Deputy Chairman &amp; Chief Executive Officer</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/86291593">Wai Cheng Hwee</a></span> <span class="data_lbl">Head-Group Technology &amp; Operations</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/86291587">Wai Fai Lee</a></span> <span class="data_lbl">Chief Financial Officer</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/4815192">Victor Ngo</a></span> <span class="data_lbl">Head-Group Compliance</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/122181365">See-Ming Ip Yeung</a></span> <span class="data_lbl">Managing Director</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/122099381">Chin Voon-Fat</a></span> <span class="data_lbl">Head-Group Wholesale Banking</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/120136914">Kok Seong Chan</a></span> <span class="data_lbl">Group Chief Risk Officer</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/115461061">Wah Yan Wong</a></span> <span class="data_lbl">Head-Group Strategy &amp; International Management</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/160726">Terence Ong</a></span> <span class="data_lbl">Head-Global Markets &amp; Investment Management</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/86328526">Chin Yong Lee</a></span> <span class="data_lbl">Head-Group Retail</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/16055509">Michael Lien</a></span> <span class="data_lbl">Non-Executive Director</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/104206">Cho Yaw Wee</a></span> <span class="data_lbl">Chairman-Emeritus</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/152463410">Carrie Ann Mathews</a></span> <span class="data_lbl">Head-Group Strategic Communications</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/120300850">Shih Tung Lin</a></span> <span class="data_lbl">Investor Relations Contact</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/95901534">Mei Leng Wong</a></span> <span class="data_lbl">Head-Group Human Resources</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/138452461">Ming Kuang Sia</a></span> <span class="data_lbl">Co-Secretary</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/151489730">Kwee Soik Sim</a></span> <span class="data_lbl">Co-Secretary</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/16489539">Fu Hua Hsieh</a></span> <span class="data_lbl">Chairman</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/86320739">Khirn Hai Yeo</a></span> <span class="data_lbl">Independent Non-Executive Director</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/154674047">Kan Seng Wong</a></span> <span class="data_lbl">Independent Non-Executive Director</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/13470908">Alexander Charles Hungate</a></span> <span class="data_lbl">Independent Non-Executive Director</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/98308786">Hwee Hua Lim</a></span> <span class="data_lbl">Independent Non-Executive Director</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/104667">Cher Siang Koh</a></span> <span class="data_lbl">Independent Non-Executive Director</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/114522422">Yew Huat Ong</a></span> <span class="data_lbl">Independent Non-Executive Director</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/86318967">Jue Hiang Cheng</a></span> <span class="data_lbl">Independent Non-Executive Director</span> </div> </li> <li> <div class="cr_data_field"> <span class="data_data"><a href="http://quotes.wsj.com/SG/XSES/U11/company-people/executive-profile/41491049">Franklin Leo Lavin</a></span> <span class="data_lbl">Independent Non-Executive Director</span> </div> </li> </ul> </div> <div class="bottomStrap_more"> <a href="#" id class="moreLink loadMoreLink">expand</a> </div> </div> </div> </div> <!--data-module-name="quotes.module.companypeople.Module"--> <div intent in-at8units-append="#at8uTarget" in-at12units-append="#at12uTarget" in-at16units-append="#at12uTarget"> <div data-module-id="12" data-module-name="quotes.module.ads.responsiveAd" data-module-zone="ads" class="zonedModule"> <div class="boxadWrapper module" id="main-quotes-ad"> <span class="adTitle">Advertisement</span> <div class="quotes-ad-wrap" id="AD_G" data-ad-options="{&quot;adId&quot;:&quot;AD_G&quot;,&quot;adUnitPath&quot;:&quot;/2/asia.wsj.com/quotes_front&quot;,&quot;adSize&quot;:[[300,250],[300,1050]],&quot;adSizeMap&quot;:null,&quot;autoRefresh&quot;:false,&quot;adTargeting&quot;:{&quot;metazone&quot;:&quot;&quot;,&quot;msrc&quot;:null,&quot;circ&quot;:&quot;nonsub&quot;,&quot;sym&quot;:&quot;U11&quot;,&quot;p39&quot;:null}}" data-tracking="asia.wsj.com/quotes_front" data-cb-ad-id="TopRectangle"> </div> </div> </div>

最佳答案

看看我已经使用了你所有的 ionic html 代码并保留了 h3 标签。 ng 风格工作正常。

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope, $http) {

/*$http.get("http://manzurul.atwebpages.com")
.success(function(response){
console.log('workingsdfsdf');

}).error(function(error){

if(!error) {
$scope.name = "No data found"
$scope.companyDescriptionStyle = {"color": "red","font-size":"40px"}
}
});*/
$scope.companyDescriptionStyle = {
"color": "blue",
"font-size": "40px"
};
$scope.name = 'World';
//Company Info
var companyInfo1 = null;
var companyInfo2 = null;

$scope.companyInfo = null;
$scope.companyInfo += "";

//Description
var description1 = "";
$scope.companyDescription = "<p></p>";


//Key People
var keyPeople1 = "";
$scope.keyPeople = "";

//Average Growth Rates
var growth = "";
var growth1 = "";
$scope.averageGrowthRates = "";
$scope.averageGrowthRates += "";

//ownership
var ownership = "";
$scope.averageGrowthRates += "";
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.11/angular.min.js"></script>
<div ng-app="plunker">
<div ng-controller="MainCtrl">
<p ng-style="nameStyle">Hello {{name}}!</p>
<ion-view view-title="Company">
<ion-nav-buttons side="left">
</ion-nav-buttons>
<ion-content id="comp">
<ion-scroll>
<h3 ng-style="companyDescriptionStyle">Company Info</h3>
<div style="margin: 10px;" ng-bind-html="companyInfo"></div>
<h3 ng-style="companyDescriptionStyle">Description</h3>
<div style="margin: 10px;font-size:20px;" ng-bind-html="companyDescription"></div>
<div style="margin: 10px;color:#AAAFFF;font-size:40px;" ng-bind-html="keyPeople"></div>
<div style="margin: 10px;" ng-bind-html="averageGrowthRates"></div>
<div style="margin: 10px;" ng-bind-html="ownership"></div>
</ion-scroll>
</ion-content>
</ion-view>
</div>
</div>

关于html - 更改 getElementsByClassName 的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45758967/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com