简体   繁体   English

HTML Parser Tag类访问

[英]Html Parser Tag class Access

I want to access a class in html code as 我想以html代码访问一个类

<id="main" class="cop">
<div class="body">
  <table class="" summary="">
     <colgroup class="game_title">//1
 <col class="thumb">
 <col class="game_title">//2
 </colgroup>

<tbody class="">
     <tr class="game">
 <td class="thumb">
 <a rel="nofollow" href=""><img src="" alt="Grudger thumbnail"></a>
 </td>
 <td class="game_title">//3

 **<div class=**"game_title"**><a href="">Grudger</a></div>//I want to access this class only** 

I used code as 我用代码作为

Element INFORM = source.getElementById("main").getAllElementByclass("game_title");

for accessing class game_title having element Gruger but this code not help. 用于访问具有元素Gruger的类game_title ,但此代码无济于事。

Try this 尝试这个

<script type="text/javascript">

   $(document).ready(function($){
      $result = $(#main .game_title).html();
   });

</script>

Try JQuery class selector 尝试JQuery类选择器

or with JavaScript try document.getElementsByClassName('game_title') 或使用JavaScript尝试document.getElementsByClassName('game_title')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM