2012-03-02 65 views
-3

我有一個結構如下,我想獲得使用jquery跨度的內容。我該怎麼做?謝謝。jQuery中獲取跨度的內容

<div id="question"> 
    <span id="question_zone_0"> 
     <span class="myclass"> 
      <span id="myword0">myword0</span> 
     </span> 
     <span class="myclass"> 
      <span id="myword1">myword1</span> 
     </span> 
    </span> 
</div> 
+3

但哪些重複? – 2012-03-02 15:56:28

+0

'$('span').text()' – 2012-03-02 15:57:05

+0

這個問題的重複:http://stackoverflow.com/questions/7960048/jquery-get-content-of-span – jzworkman 2012-03-02 15:57:31

回答

1

你可以做

var span0 = $('#myword0').text(); 
var span1 = $('#myword1').text(); 

或相互

$('#question span').each(function(){ 
    alert($(this).text()); 
})