2012-07-06 41 views
0

我寫的下面,顯示文本,當我點擊鏈接更多的,它必須顯示剩餘款。我已經嘗試過,但我不知道爲什麼它不工作,可以幫助解決這個問題。地方的文本,當我們點擊更多按鈕

這是我下面的代碼

<style> 
    p span { 
     display:none; 
    } 

</style> 

<script type="javascript"> 
$('a').click(function() { 
    $(this).next().show(); 
    return false; 
}); 

</script> 


<table cellpadding:0px;cellspacing:0px;border=0px; width="100%"> 
<tr> 
<td style="width:20%"><a><button class="choosesub_but comingsoon"> list</button></a></td> 

<td style="width:47%;"><p style="font:13px verdana;">A written work—be it an essay or a story—is about an idea or concept. An essay explains it; a story narrates it.<a href="#" style="text-decoration:underline;">More...</a> 
<span>all to entertain the reader. All paragraphs support each other, leading the reader from the first idea to the final resolution of the written piece of work.</span></p> 
</td> 
<td style="width:30%;"><ul class="choosesub_ul"><li><a href="#">Community event</a></li></ul></td> 
</tr> 
</table> 

當我點擊更多的鏈接,它顯示輸出

的書面工作,無論是一篇文章或一個故事,是關於一個想法或概念。一篇散文解釋它;一個故事敘述它。更多...所有的娛樂讀者。所有段落相互支持,導致從最初的想法到書面作品的最終解決讀者..

回答

1
<script type="text/javascript"> 
$(function() { 
    $('a').click(function() { 
     $(this).next().show(); 
     return false; 
    }); 
}); 
</script> 

您不能綁定到的鏈接,如果該鏈接尚未加載單擊事件。所以我們把這段代碼放在document.ready區塊中,這樣它在所有東西都加載完畢後執行。

而且腳本類型應該是type="text/javascript"

+0

沒有,它不工作 – lucky 2012-07-06 17:26:25

+0

然後別的東西,你不向我們展示了導致問題。 http://jsbin.com/otojor – sachleen 2012-07-06 17:29:08

+0

雅,其我我已經放置 – lucky 2012-07-06 17:29:33

0
<script> 

     $('a').on('click',function() { 
      alert("123"); 
      $(this).siblings().show() 
     }); 
    </script> 
+0

不,我試過。它也不工作 – lucky 2012-07-06 17:45:00

+1

@kanya你不是很清楚。實際上根本不清楚。兩種解決方案都可以工當你實施它們時,它們不起作用。向我們展示您的其他代碼。 「不起作用」不足以幫助你。 – sachleen 2012-07-06 17:48:55